summaryrefslogtreecommitdiff
path: root/Sora/Data/Settings
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-23 22:02:59 -0800
committerFuwn <[email protected]>2026-02-23 22:02:59 -0800
commit7904b2366a28fca2585b5f5ec0588412e10f0c94 (patch)
treee57236200c0f377d0d06f1c90231551f7be3dbed /Sora/Data/Settings
parentfeat: localize accessibility fallback and value strings (diff)
downloadsora-testing-main.tar.xz
sora-testing-main.zip
perf: cache danbooru page token floor and reuse search-history payloadsHEADmain
Diffstat (limited to 'Sora/Data/Settings')
-rw-r--r--Sora/Data/Settings/SettingsManager.swift20
1 files changed, 14 insertions, 6 deletions
diff --git a/Sora/Data/Settings/SettingsManager.swift b/Sora/Data/Settings/SettingsManager.swift
index b07b38c..78aef7c 100644
--- a/Sora/Data/Settings/SettingsManager.swift
+++ b/Sora/Data/Settings/SettingsManager.swift
@@ -198,13 +198,17 @@ class SettingsManager: ObservableObject { // swiftlint:disable:this type_body_l
defer { isUpdatingCache = false }
+ let sortedSearchHistory = newValue.sorted { $0.date > $1.date }
+ let payload = SettingsCodec.encodeOnce(sortedSearchHistory)
+
syncableData(
key: "searchHistory",
localData: $searchHistoryData,
- newValue: newValue,
- ) { $0.sorted { $0.date > $1.date } }
+ newValue: sortedSearchHistory,
+ encodedData: payload?.encodedData
+ ) { $0 }
- searchHistoryCache = newValue.sorted { $0.date > $1.date }
+ searchHistoryCache = sortedSearchHistory
pendingSyncKeys.insert(.searchHistory)
triggerBatchedSync()
@@ -427,13 +431,17 @@ class SettingsManager: ObservableObject { // swiftlint:disable:this type_body_l
defer { isUpdatingCache = false }
+ let sortedSearchHistory = newValue.sorted { $0.date > $1.date }
+ let payload = SettingsCodec.encodeOnce(sortedSearchHistory)
+
syncableData(
key: "searchHistory",
localData: $searchHistoryData,
- newValue: newValue,
- ) { $0.sorted { $0.date > $1.date } }
+ newValue: sortedSearchHistory,
+ encodedData: payload?.encodedData
+ ) { $0 }
- searchHistoryCache = newValue.sorted { $0.date > $1.date }
+ searchHistoryCache = sortedSearchHistory
pendingSyncKeys.insert(.searchHistory)
triggerBatchedSync()