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

@@ -49,6 +49,7 @@ export enum ApplicationEvent {
/** When StorageService is ready (but NOT yet decrypted) to start servicing read/write requests */
StorageReady = 'Application:StorageReady',
PreferencesChanged = 'Application:PreferencesChanged',
LocalPreferencesChanged = 'Application:LocalPreferencesChanged',
UnprotectedSessionBegan = 'Application:UnprotectedSessionBegan',
UserRolesChanged = 'Application:UserRolesChanged',
FeaturesAvailabilityChanged = 'Application:FeaturesAvailabilityChanged',

View File

@@ -0,0 +1,15 @@
export enum LocalPrefKey {
ActiveThemes = 'activeThemes',
UseSystemColorScheme = 'useSystemColorScheme',
UseTranslucentUI = 'useTranslucentUI',
AutoLightThemeIdentifier = 'autoLightThemeIdentifier',
AutoDarkThemeIdentifier = 'autoDarkThemeIdentifier',
}
export type LocalPrefValue = {
[LocalPrefKey.ActiveThemes]: string[]
[LocalPrefKey.UseSystemColorScheme]: boolean
[LocalPrefKey.UseTranslucentUI]: boolean
[LocalPrefKey.AutoLightThemeIdentifier]: string
[LocalPrefKey.AutoDarkThemeIdentifier]: string
}

View File

@@ -1,7 +1,9 @@
import { PrefKey, PrefValue } from '@standardnotes/models'
import { AbstractService } from '../Service/AbstractService'
import { LocalPrefKey, LocalPrefValue } from './LocalPrefKey'
export enum PreferencesServiceEvent {
LocalPreferencesChanged = 'LocalPreferencesChanged',
PreferencesChanged = 'PreferencesChanged',
}
@@ -10,7 +12,15 @@ export interface PreferenceServiceInterface extends AbstractService<PreferencesS
getValue<K extends PrefKey>(key: K, defaultValue?: PrefValue[K]): PrefValue[K] | undefined
getValue<K extends PrefKey>(key: K, defaultValue: PrefValue[K] | undefined): PrefValue[K] | undefined
getLocalValue<K extends LocalPrefKey>(key: K, defaultValue: LocalPrefValue[K]): LocalPrefValue[K]
getLocalValue<K extends LocalPrefKey>(key: K, defaultValue?: LocalPrefValue[K]): LocalPrefValue[K] | undefined
getLocalValue<K extends LocalPrefKey>(
key: K,
defaultValue: LocalPrefValue[K] | undefined,
): LocalPrefValue[K] | undefined
setValue<K extends PrefKey>(key: K, value: PrefValue[K]): Promise<void>
/** Set value without triggering sync or event notifications */
setValueDetached<K extends PrefKey>(key: K, value: PrefValue[K]): Promise<void>
setLocalValue<K extends LocalPrefKey>(key: K, value: LocalPrefValue[K]): void
}

View File

@@ -50,6 +50,7 @@ export enum StorageKey {
FileBackupsLocation = 'file_backups_location',
VaultSelectionOptions = 'vault_selection_options',
Subscription = 'subscription',
LocalPreferences = 'local_preferences',
}
export enum NonwrappedStorageKey {

View File

@@ -134,6 +134,7 @@ export * from './KeySystem/KeySystemKeyManager'
export * from './Mfa/MfaServiceInterface'
export * from './Mutator/MutatorClientInterface'
export * from './Payloads/PayloadManagerInterface'
export * from './Preferences/LocalPrefKey'
export * from './Preferences/PreferenceId'
export * from './Preferences/PreferenceServiceInterface'
export * from './Protection/MobileUnlockTiming'