🚑️ Fix #4938 - Theme persistence

When setting a new theme, these three functions need to run in sequence.

AppDefaults.shared.currentThemeName = newValue
updateThemeNames()
updateCurrentTheme()

Within updateThemeNames() there is a `Task { @MainActor in }` that allows  `updateCurrentTheme()` to complete before `updateThemeNames()`. In this scenario, when `updateCurrentTheme() is run the app hasnt got an itinerary of installed themes, so it sets the current them back to Default.

Removing the `Task` fixes the persistence issue.
This commit is contained in:
Stuart Breckenridge committed 2026-01-10 10:42:54 +08:00
1 parent 3792cd3eda
commit fd860b8cd5
1 file changed
+2 -4
@@ -160,10 +160,8 @@ private extension ArticleThemesManager {
let allThemeNames = appThemeNames.union(installedThemeNames)
let sortedThemeNames = allThemeNames.sorted(by: { $0.compare($1, options: .caseInsensitive) == .orderedAscending })
Task { @MainActor in
if sortedThemeNames != themeNames {
themeNames = sortedThemeNames
}
if sortedThemeNames != themeNames {
themeNames = sortedThemeNames
}
}