mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
f
This commit is contained in:
parent
c74a4e736e
commit
e7af55e4ed
3 changed files with 28 additions and 7 deletions
|
|
@ -195,12 +195,20 @@ extension JSContext {
|
||||||
|
|
||||||
let callReject: (String) -> Void = { message in
|
let callReject: (String) -> Void = { message in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
reject.call(withArguments: [message])
|
if !reject.isUndefined {
|
||||||
|
reject.call(withArguments: [message])
|
||||||
|
} else {
|
||||||
|
Logger.shared.log("Reject callback is undefined", type: "Error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let callResolve: ([String: Any]) -> Void = { dict in
|
let callResolve: ([String: Any]) -> Void = { dict in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
resolve.call(withArguments: [dict])
|
if !resolve.isUndefined {
|
||||||
|
resolve.call(withArguments: [dict])
|
||||||
|
} else {
|
||||||
|
Logger.shared.log("Resolve callback is undefined", type: "Error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,12 @@ extension JSController {
|
||||||
guard let promiseDetails = promiseValueDetails else {
|
guard let promiseDetails = promiseValueDetails else {
|
||||||
Logger.shared.log("extractDetails did not return a Promise", type: "Error")
|
Logger.shared.log("extractDetails did not return a Promise", type: "Error")
|
||||||
detailsGroupQueue.sync {
|
detailsGroupQueue.sync {
|
||||||
guard !hasLeftDetailsGroup else { return }
|
guard !hasLeftDetailsGroup else {
|
||||||
|
Logger.shared.log("extractDetails: guard block called but group already left", type: "Debug")
|
||||||
|
return
|
||||||
|
}
|
||||||
hasLeftDetailsGroup = true
|
hasLeftDetailsGroup = true
|
||||||
|
Logger.shared.log("Leaving dispatch group due to nil promise (details)", type: "Debug")
|
||||||
dispatchGroup.leave()
|
dispatchGroup.leave()
|
||||||
}
|
}
|
||||||
completion([], [])
|
completion([], [])
|
||||||
|
|
@ -136,6 +140,7 @@ extension JSController {
|
||||||
} else {
|
} else {
|
||||||
Logger.shared.log("Result is not a string of extractDetails", type: "Error")
|
Logger.shared.log("Result is not a string of extractDetails", type: "Error")
|
||||||
}
|
}
|
||||||
|
Logger.shared.log("Leaving dispatch group from details thenBlock", type: "Debug")
|
||||||
dispatchGroup.leave()
|
dispatchGroup.leave()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,6 +154,7 @@ extension JSController {
|
||||||
hasLeftDetailsGroup = true
|
hasLeftDetailsGroup = true
|
||||||
|
|
||||||
Logger.shared.log("Promise rejected of extractDetails: \(String(describing: error.toString()))", type: "Error")
|
Logger.shared.log("Promise rejected of extractDetails: \(String(describing: error.toString()))", type: "Error")
|
||||||
|
Logger.shared.log("Leaving dispatch group from details catchBlock", type: "Debug")
|
||||||
dispatchGroup.leave()
|
dispatchGroup.leave()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -173,6 +179,7 @@ extension JSController {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
hasLeftEpisodesGroup = true
|
hasLeftEpisodesGroup = true
|
||||||
|
Logger.shared.log("Leaving dispatch group due to timeout", type: "Debug")
|
||||||
dispatchGroup.leave()
|
dispatchGroup.leave()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -182,8 +189,12 @@ extension JSController {
|
||||||
Logger.shared.log("extractEpisodes did not return a Promise", type: "Error")
|
Logger.shared.log("extractEpisodes did not return a Promise", type: "Error")
|
||||||
timeoutWorkItem.cancel()
|
timeoutWorkItem.cancel()
|
||||||
episodesGroupQueue.sync {
|
episodesGroupQueue.sync {
|
||||||
guard !hasLeftEpisodesGroup else { return }
|
guard !hasLeftEpisodesGroup else {
|
||||||
|
Logger.shared.log("extractEpisodes: guard block called but group already left", type: "Debug")
|
||||||
|
return
|
||||||
|
}
|
||||||
hasLeftEpisodesGroup = true
|
hasLeftEpisodesGroup = true
|
||||||
|
Logger.shared.log("Leaving dispatch group due to nil promise", type: "Debug")
|
||||||
dispatchGroup.leave()
|
dispatchGroup.leave()
|
||||||
}
|
}
|
||||||
completion([], [])
|
completion([], [])
|
||||||
|
|
@ -220,6 +231,7 @@ extension JSController {
|
||||||
} else {
|
} else {
|
||||||
Logger.shared.log("Result is not a string of extractEpisodes", type: "Error")
|
Logger.shared.log("Result is not a string of extractEpisodes", type: "Error")
|
||||||
}
|
}
|
||||||
|
Logger.shared.log("Leaving dispatch group from thenBlock", type: "Debug")
|
||||||
dispatchGroup.leave()
|
dispatchGroup.leave()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -234,6 +246,7 @@ extension JSController {
|
||||||
hasLeftEpisodesGroup = true
|
hasLeftEpisodesGroup = true
|
||||||
|
|
||||||
Logger.shared.log("Promise rejected of extractEpisodes: \(String(describing: error.toString()))", type: "Error")
|
Logger.shared.log("Promise rejected of extractEpisodes: \(String(describing: error.toString()))", type: "Error")
|
||||||
|
Logger.shared.log("Leaving dispatch group from catchBlock", type: "Debug")
|
||||||
dispatchGroup.leave()
|
dispatchGroup.leave()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -305,10 +305,10 @@ struct SettingsViewPlayer: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsSection(title: NSLocalizedString("Progress bar Marker Color", comment: "")) {
|
SettingsSection(title: NSLocalizedString("Progress bar Marker Color", comment: "")) {
|
||||||
ColorPicker(NSLocalizedString("Segments Color", comment: ""), selection: Binding(
|
ColorPicker(NSLocalizedString("Segments Color", comment: ""), selection: Binding<Color>(
|
||||||
get: {
|
get: {
|
||||||
if let data = UserDefaults.standard.data(forKey: "segmentsColorData"),
|
if let data = UserDefaults.standard.data(forKey: "segmentsColorData"),
|
||||||
let uiColor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? UIColor {
|
let uiColor = try? NSKeyedUnarchiver.unarchivedObject(ofClass: UIColor.self, from: data) {
|
||||||
return Color(uiColor)
|
return Color(uiColor)
|
||||||
}
|
}
|
||||||
return .yellow
|
return .yellow
|
||||||
|
|
@ -322,7 +322,7 @@ struct SettingsViewPlayer: View {
|
||||||
UserDefaults.standard.set(data, forKey: "segmentsColorData")
|
UserDefaults.standard.set(data, forKey: "segmentsColorData")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
))
|
), supportsOpacity: false)
|
||||||
.padding(.horizontal, 16)
|
.padding(.horizontal, 16)
|
||||||
.padding(.vertical, 12)
|
.padding(.vertical, 12)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue