mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
sduj (#102)
* Implementation of loading modal * little things but this is good * Update README.md * dim mode * hello 👋 (#95) * bug fix dimming * improved the fetchEpisodeMetadata logic * Aniskip logic and basic buttons (#96) * Aniskip logic and basic buttons * good fuckin enough for now * im callin good enough * bug fix * its something * hallelujah * Update SearchView.swift * made subs go up the progress bar if it is showing --------- Co-authored-by: Seiike <122684677+Seeike@users.noreply.github.com> Co-authored-by: Francesco <100066266+cranci1@users.noreply.github.com> * Updated workflow to change file extension from .zip to .ipa for easier access. (#98) * Update README.md * Auto: Update IPA [skip ci] * Color picker in settings for intro and outro segments (#99) * Color picker in settings for intro and outro segments * Color picker in settings for intro and outro segments * Auto: Update IPA [skip ci] --------- Co-authored-by: cranci1 <cranci1@github.com> * fixed crash???? please yes * Auto: Update IPA [skip ci] * even more handling crazy fixes * Auto: Update IPA [skip ci] --------- Co-authored-by: Ibrahim Sulejmenov <batonchik2004@gmail.com> Co-authored-by: ibro <54913038+xibrox@users.noreply.github.com> Co-authored-by: Seiike <122684677+Seeike@users.noreply.github.com> Co-authored-by: bshar <98615778+bshar1865@users.noreply.github.com> Co-authored-by: cranci1 <cranci1@github.com>
This commit is contained in:
parent
00586fcf3e
commit
0cc8f9166d
2 changed files with 56 additions and 9 deletions
|
|
@ -14,6 +14,15 @@ class ModuleManager: ObservableObject {
|
|||
private let modulesFileName = "modules.json"
|
||||
|
||||
init() {
|
||||
let url = getModulesFilePath()
|
||||
if (!FileManager.default.fileExists(atPath: url.path)) {
|
||||
do {
|
||||
try "[]".write(to: url, atomically: true, encoding: .utf8)
|
||||
Logger.shared.log("Created empty modules file", type: "Info")
|
||||
} catch {
|
||||
Logger.shared.log("Failed to create modules file: \(error.localizedDescription)", type: "Error")
|
||||
}
|
||||
}
|
||||
loadModules()
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleModulesSyncCompleted), name: .modulesSyncDidComplete, object: nil)
|
||||
}
|
||||
|
|
@ -23,12 +32,25 @@ class ModuleManager: ObservableObject {
|
|||
}
|
||||
|
||||
@objc private func handleModulesSyncCompleted() {
|
||||
DispatchQueue.main.async {
|
||||
self.loadModules()
|
||||
Task {
|
||||
await self.checkJSModuleFiles()
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self = self else { return }
|
||||
|
||||
do {
|
||||
let url = self.getModulesFilePath()
|
||||
if FileManager.default.fileExists(atPath: url.path) {
|
||||
self.loadModules()
|
||||
Task {
|
||||
await self.checkJSModuleFiles()
|
||||
}
|
||||
Logger.shared.log("Reloaded modules after iCloud sync")
|
||||
} else {
|
||||
Logger.shared.log("No modules file found after sync", type: "Error")
|
||||
self.modules = []
|
||||
}
|
||||
} catch {
|
||||
Logger.shared.log("Error handling modules sync: \(error.localizedDescription)", type: "Error")
|
||||
self.modules = []
|
||||
}
|
||||
Logger.shared.log("Reloaded modules after iCloud sync")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -42,11 +64,36 @@ class ModuleManager: ObservableObject {
|
|||
|
||||
func loadModules() {
|
||||
let url = getModulesFilePath()
|
||||
guard let data = try? Data(contentsOf: url) else { return }
|
||||
modules = (try? JSONDecoder().decode([ScrapingModule].self, from: data)) ?? []
|
||||
|
||||
Task {
|
||||
await checkJSModuleFiles()
|
||||
guard FileManager.default.fileExists(atPath: url.path) else {
|
||||
Logger.shared.log("Modules file does not exist, creating empty one", type: "Info")
|
||||
do {
|
||||
try "[]".write(to: url, atomically: true, encoding: .utf8)
|
||||
modules = []
|
||||
} catch {
|
||||
Logger.shared.log("Failed to create modules file: \(error.localizedDescription)", type: "Error")
|
||||
modules = []
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
let data = try Data(contentsOf: url)
|
||||
do {
|
||||
let decodedModules = try JSONDecoder().decode([ScrapingModule].self, from: data)
|
||||
modules = decodedModules
|
||||
|
||||
Task {
|
||||
await checkJSModuleFiles()
|
||||
}
|
||||
} catch {
|
||||
Logger.shared.log("Failed to decode modules: \(error.localizedDescription)", type: "Error")
|
||||
try "[]".write(to: url, atomically: true, encoding: .utf8)
|
||||
modules = []
|
||||
}
|
||||
} catch {
|
||||
Logger.shared.log("Failed to load modules file: \(error.localizedDescription)", type: "Error")
|
||||
modules = []
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in a new issue