diff options
| author | Fuwn <[email protected]> | 2025-07-24 19:04:00 +0200 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-07-24 19:04:00 +0200 |
| commit | f679f1126374149b8259e62493209f27edb200d6 (patch) | |
| tree | cc0c4a74e3275dc0988962fa31dbe31e574e9656 /Sora/Data | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-f679f1126374149b8259e62493209f27edb200d6.tar.xz sora-testing-f679f1126374149b8259e62493209f27edb200d6.zip | |
feat: Development commit
Diffstat (limited to 'Sora/Data')
| -rw-r--r-- | Sora/Data/Booru/BooruManager.swift | 2 | ||||
| -rw-r--r-- | Sora/Data/Booru/BooruPageCacheEntry.swift | 8 | ||||
| -rw-r--r-- | Sora/Data/Settings/SettingsManager.swift | 8 |
3 files changed, 13 insertions, 5 deletions
diff --git a/Sora/Data/Booru/BooruManager.swift b/Sora/Data/Booru/BooruManager.swift index 5530d7c..59bdf24 100644 --- a/Sora/Data/Booru/BooruManager.swift +++ b/Sora/Data/Booru/BooruManager.swift @@ -41,7 +41,7 @@ class BooruManager: ObservableObject { // swiftlint:disable:this type_body_leng init( _ provider: BooruProvider, credentials: BooruProviderCredentials? = nil, - cacheDuration: TimeInterval = 300 + cacheDuration: TimeInterval = BooruPageCacheEntry.defaultExpiration ) { self.provider = provider self.flavor = BooruProviderFlavor(provider: provider) diff --git a/Sora/Data/Booru/BooruPageCacheEntry.swift b/Sora/Data/Booru/BooruPageCacheEntry.swift index 29fc419..7589aad 100644 --- a/Sora/Data/Booru/BooruPageCacheEntry.swift +++ b/Sora/Data/Booru/BooruPageCacheEntry.swift @@ -1,6 +1,8 @@ import Foundation class BooruPageCacheEntry { + static let defaultExpiration: TimeInterval = 300 + let posts: [BooruPost] let timestamp: Date private let expiration: TimeInterval @@ -9,7 +11,11 @@ class BooruPageCacheEntry { Date().timeIntervalSince(timestamp) > expiration } - init(posts: [BooruPost], timestamp: Date, expiration: TimeInterval = 300) { + init( + posts: [BooruPost], + timestamp: Date, + expiration: TimeInterval = BooruPageCacheEntry.defaultExpiration + ) { self.posts = posts self.timestamp = timestamp self.expiration = expiration diff --git a/Sora/Data/Settings/SettingsManager.swift b/Sora/Data/Settings/SettingsManager.swift index 44b3526..0d20dfa 100644 --- a/Sora/Data/Settings/SettingsManager.swift +++ b/Sora/Data/Settings/SettingsManager.swift @@ -224,9 +224,11 @@ class SettingsManager: ObservableObject { // swiftlint:disable:this type_body_l let key = credentials.provider let value = extract(credentials) - if dictionary[key] == nil { - dictionary[key] = value - } else if isDefault(dictionary[key]!) && !isDefault(value) { + if let existing = dictionary[key] { + if isDefault(existing) && !isDefault(value) { + dictionary[key] = value + } + } else { dictionary[key] = value } } |