feat: Themes and appeareance settings are now local to your device and not synced (#2847)

This commit is contained in:
Aman Harwara
2024-02-17 14:23:37 +05:30
committed by GitHub
parent 3d1a038393
commit bfbf9ab8ce
18 changed files with 250 additions and 117 deletions

View File

@@ -0,0 +1,55 @@
import { LocalPrefKey, ApplicationStage } from '@standardnotes/services'
import { Migration } from '@Lib/Migrations/Migration'
import { PrefDefaults, PrefKey } from '@standardnotes/models'
export class Migration2_208_0 extends Migration {
static override version(): string {
return '2.208.0'
}
protected registerStageHandlers(): void {
this.registerStageHandler(ApplicationStage.FullSyncCompleted_13, async () => {
await this.migrateSyncedPreferencesToLocal()
this.markDone()
})
}
private async migrateSyncedPreferencesToLocal(): Promise<void> {
this.services.preferences.setLocalValue(
LocalPrefKey.ActiveThemes,
this.services.preferences.getValue(
PrefKey.DEPRECATED_ActiveThemes,
PrefDefaults[PrefKey.DEPRECATED_ActiveThemes],
),
)
this.services.preferences.setLocalValue(
LocalPrefKey.UseSystemColorScheme,
this.services.preferences.getValue(
PrefKey.DEPRECATED_UseSystemColorScheme,
PrefDefaults[PrefKey.DEPRECATED_UseSystemColorScheme],
),
)
this.services.preferences.setLocalValue(
LocalPrefKey.AutoLightThemeIdentifier,
this.services.preferences.getValue(
PrefKey.DEPRECATED_AutoLightThemeIdentifier,
PrefDefaults[PrefKey.DEPRECATED_AutoLightThemeIdentifier],
),
)
this.services.preferences.setLocalValue(
LocalPrefKey.AutoDarkThemeIdentifier,
this.services.preferences.getValue(
PrefKey.DEPRECATED_AutoDarkThemeIdentifier,
PrefDefaults[PrefKey.DEPRECATED_AutoDarkThemeIdentifier],
),
)
this.services.preferences.setLocalValue(
LocalPrefKey.UseTranslucentUI,
this.services.preferences.getValue(
PrefKey.DEPRECATED_UseTranslucentUI,
PrefDefaults[PrefKey.DEPRECATED_UseTranslucentUI],
),
)
}
}