Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(app): scope themes per account and zoom per device

Hampus40cf64347f7b
diff --git a/fluxer_app/src/features/app/components/dialogs/components/AllSettingsRenderer.tsx b/fluxer_app/src/features/app/components/dialogs/components/AllSettingsRenderer.tsx
index 4bf9a8786..4a0c69b13 100644
--- a/fluxer_app/src/features/app/components/dialogs/components/AllSettingsRenderer.tsx
+++ b/fluxer_app/src/features/app/components/dialogs/components/AllSettingsRenderer.tsx
@@ -8,6 +8,8 @@ import {
setHighlightRanges,
} from '@app/features/messaging/utils/CSSHighlightSearch';
import {remFromPx} from '@app/features/theme/layout/RemFromPx';
+import {ThemesInlineContent} from '@app/features/theme_settings/ThemesTab';
+import {CaretRightIcon} from '@app/features/ui/icons/DirectionalIcons';
import {AccessibilityInlineContent} from '@app/features/user/components/modals/tabs/AccessibilityTab';
import {AppearanceInlineContent} from '@app/features/user/components/modals/tabs/AppearanceTab';
import {AccountSecurityInlineTab} from '@app/features/user/components/modals/tabs/account_security_tab/AccountSecurityTabInline';
@@ -38,7 +40,6 @@ import type {
import {SettingsItemStatusBadges} from '@app/features/user/components/settings_utils/SettingsStatusBadge';
import Users from '@app/features/user/state/Users';
import {Plural, Trans} from '@lingui/react/macro';
-import {CaretRightIcon} from '@phosphor-icons/react';
import {clsx} from 'clsx';
import {observer} from 'mobx-react-lite';
import React, {useCallback, useEffect, useRef, useState} from 'react';
@@ -69,6 +70,7 @@ const INLINE_TAB_COMPONENTS: Partial<Record<UserSettingsTabType, React.Component
blocked_users: AccountSecurityInlineTab,
devices: AccountSecurityInlineTab,
appearance: AppearanceInlineContent,
+ themes: ThemesInlineContent,
accessibility: AccessibilityInlineContent,
chat_settings: ChatSettingsInlineContent,
voice_video: VoiceVideoInlineContent,
diff --git a/fluxer_app/src/features/app/hooks/useDesktopElectronBridges.tsx b/fluxer_app/src/features/app/hooks/useDesktopElectronBridges.tsx
index 178dcb9c4..f1884ec12 100644
--- a/fluxer_app/src/features/app/hooks/useDesktopElectronBridges.tsx
+++ b/fluxer_app/src/features/app/hooks/useDesktopElectronBridges.tsx
@@ -7,7 +7,6 @@ import {Logger} from '@app/features/platform/utils/AppLogger';
import {initializeDesktopTrayBridge} from '@app/features/platform/utils/DesktopTrayBridge';
import {loadLazyModule} from '@app/features/platform/utils/LazyModuleLoader';
import ThemeLibrary from '@app/features/theme/state/ThemeLibrary';
-import {broadcastThemeStudioMessage} from '@app/features/theme_studio/state/ThemeStudioBroadcast';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
import {getElectronAPI} from '@app/features/ui/utils/NativeUtils';
import {startLiveResizeTracking} from '@app/features/window/state/LiveResize';
@@ -25,9 +24,7 @@ export function useDesktopElectronBridges(): void {
});
const electronApi = getElectronAPI();
if (!electronApi) return;
- const disposeLinkedFileSync = ThemeLibrary.startLinkedFileSync({
- onThemesChanged: () => broadcastThemeStudioMessage({type: 'themeLibrary', revision: ThemeLibrary.revision}),
- });
+ const disposeLinkedFileSync = ThemeLibrary.startLinkedFileSync();
const adjustZoom = (direction: 1 | -1) => {
void Accessibility.adjustZoom(direction).catch((error: unknown) => {
logger.error('Failed to adjust the zoom level', error);
diff --git a/fluxer_app/src/features/platform/state/AppStorageKeys.ts b/fluxer_app/src/features/platform/state/AppStorageKeys.ts
index 9c5c0750a..8c945c7d3 100644
--- a/fluxer_app/src/features/platform/state/AppStorageKeys.ts
+++ b/fluxer_app/src/features/platform/state/AppStorageKeys.ts
@@ -4,7 +4,10 @@ import {AuthSessionStorageKey} from '@app/features/platform/state/auth_session/A
export const AppStorageKey = Object.freeze({
ACCESSIBILITY_LEGACY_STORE: 'Accessibility',
+ ACCOUNT_KEYBINDS: 'AccountKeybinds',
ACCOUNT_RESET_KEPT_KEYS: 'fluxer:internal:account-reset-kept-keys',
+ ACCOUNT_THEME: 'AccountTheme',
+ ACCOUNT_THEME_MODE: 'AccountThemeMode',
AUTH_ACCOUNT_KEY: AuthSessionStorageKey.ActiveAccountKey,
AUTH_DESKTOP_CLIENT_INTRO_COMPLETED: 'fluxer:auth:desktop-client-intro:completed',
AUTH_DESKTOP_CLIENT_PERMISSIONS_SKIPPED: 'fluxer:auth:desktop-client-intro:permissions-skipped',
@@ -14,18 +17,22 @@ export const AppStorageKey = Object.freeze({
AUTH_SESSION_USER_ID: AuthSessionStorageKey.UserId,
DELETED_KEYS: 'fluxer:internal:deleted-keys',
I18N_CHOSEN_LOCALE: 'fluxer:i18n:chosen-locale',
+ INSTALLATION_THEME: 'InstallationTheme',
MESSAGING_DRAFTS: 'Drafts',
MESSAGING_MESSAGE_EDIT: 'MessageEdit',
NOTIFICATION: 'Notification',
SSO_PENDING_CONTEXT_PREFIX: 'fluxer:sso:pending-context',
THEME: 'Theme',
+ THEME_LIBRARY_ACCOUNT_ENABLED_IDS: 'fluxer:theme-library:account-enabled-ids',
THEME_LIBRARY_ENABLED_IDS: 'fluxer:theme-library:enabled-ids',
THEME_LIBRARY_LOCAL_FILES: 'fluxer:theme-library:local-files',
THEME_LIBRARY_MIGRATED: 'fluxer:theme-library:migrated-to-app-storage',
THEME_LIBRARY_THEMES: 'fluxer:theme-library:themes',
THEME_PREBOOT_MIRROR: 'theme',
+ THEME_PROFILES_MIGRATED: 'ThemeProfiles:migrated:v1',
UI_CHANNEL_PINS_POPOUT_SIZE: 'fluxer:ui:channel-pins-popout-size',
UI_EXPRESSION_PICKER_SIZE: 'fluxer:ui:expression-picker-size',
+ UI_INBOX_OTHER_ACCOUNTS_COLLAPSED: 'fluxer:ui:inbox-other-accounts-collapsed',
UI_INBOX_POPOUT_SIZE: 'fluxer:ui:inbox-popout-size',
UI_SIDEBAR_WIDTH: 'fluxer:ui:sidebar-width',
VOICE_SETTINGS: 'VoiceSettings',
@@ -43,6 +50,7 @@ export const LegacySharedContentReviewState = Object.freeze({
} as const);
const GLOBAL_APP_STORAGE_KEY_LOOKUP: Readonly<Record<string, true>> = Object.freeze({
+ [AppStorageKey.ACCOUNT_KEYBINDS]: true,
[AppStorageKey.AUTH_ACCOUNT_KEY]: true,
[AppStorageKey.AUTH_DESKTOP_CLIENT_INTRO_COMPLETED]: true,
[AppStorageKey.AUTH_DESKTOP_CLIENT_PERMISSIONS_SKIPPED]: true,
@@ -51,10 +59,13 @@ const GLOBAL_APP_STORAGE_KEY_LOOKUP: Readonly<Record<string, true>> = Object.fre
[AppStorageKey.AUTH_SESSION_TOKEN]: true,
[AppStorageKey.AUTH_SESSION_USER_ID]: true,
[AppStorageKey.I18N_CHOSEN_LOCALE]: true,
+ [AppStorageKey.INSTALLATION_THEME]: true,
[AppStorageKey.THEME_LIBRARY_ENABLED_IDS]: true,
[AppStorageKey.THEME_LIBRARY_LOCAL_FILES]: true,
[AppStorageKey.THEME_LIBRARY_MIGRATED]: true,
[AppStorageKey.THEME_LIBRARY_THEMES]: true,
+ [AppStorageKey.THEME_PROFILES_MIGRATED]: true,
+ [AppStorageKey.UI_INBOX_OTHER_ACCOUNTS_COLLAPSED]: true,
[AppStorageKey.WINDOWS_FONT]: true,
});
diff --git a/fluxer_app/src/features/platform/state/LegacyAppStorageKeyMap.ts b/fluxer_app/src/features/platform/state/LegacyAppStorageKeyMap.ts
index b62e6bb23..23ec98d37 100644
--- a/fluxer_app/src/features/platform/state/LegacyAppStorageKeyMap.ts
+++ b/fluxer_app/src/features/platform/state/LegacyAppStorageKeyMap.ts
@@ -106,7 +106,7 @@ const PLAIN_ROWS: ReadonlyArray<LegacyAppStorageKeyRow> = [
const ACCESSIBILITY_ROWS: ReadonlyArray<LegacyAppStorageKeyRow> = [
{kind: 'exact', key: AppStorageKey.ACCESSIBILITY_LEGACY_STORE, scope: 'account', fanout: 'preference'},
- {kind: 'exact', key: 'Accessibility:zoomLevel', scope: 'account', fanout: 'preference'},
+ {kind: 'exact', key: 'Accessibility:zoomLevel', scope: 'global', fanout: 'preference'},
{kind: 'exact', key: 'Accessibility:customThemeCss', scope: 'account', fanout: 'preference'},
{kind: 'exact', key: 'Accessibility:customThemeCssSyncAcrossDevices', scope: 'account', fanout: 'preference'},
{kind: 'exact', key: 'Accessibility:motion', scope: 'account', fanout: 'preference'},
@@ -122,7 +122,7 @@ export const LEGACY_APP_STORAGE_KEY_MAP: ReadonlyArray<LegacyAppStorageKeyRow> =
...ACCESSIBILITY_ROWS,
]);
-export const NOT_MIGRATED_LEGACY_KEYS: ReadonlyArray<string> = Object.freeze([
+const NOT_MIGRATED_LEGACY_KEYS: ReadonlyArray<string> = Object.freeze([
AppStorageKey.AUTH_SESSION_TOKEN,
AppStorageKey.AUTH_SESSION_USER_ID,
'runtimeConfig',
diff --git a/fluxer_app/src/features/platform/state/PersistentStorage.ts b/fluxer_app/src/features/platform/state/PersistentStorage.ts
index 43f8396b5..2d32bb975 100644
--- a/fluxer_app/src/features/platform/state/PersistentStorage.ts
+++ b/fluxer_app/src/features/platform/state/PersistentStorage.ts
@@ -28,10 +28,11 @@ import {
rawStorageKind,
readRawStorageItem,
writeRawStorageItem,
+ ZOOM_PREBOOT_MIRROR_STORAGE_KEY,
} from '@app/features/platform/state/PrebootMirror';
import {countTelemetryEvent, TelemetryEvent} from '@app/features/platform/utils/AppTelemetry';
-export type StorageChangeSource = 'local' | 'external';
+type StorageChangeSource = 'local' | 'external';
export interface StorageChangeEvent {
key: string | null;
@@ -75,14 +76,13 @@ interface LoadedScopeCache {
export const GLOBAL_APP_STORAGE_SCOPE = 'global';
export const UNAUTHENTICATED_APP_STORAGE_SCOPE = 'unauthenticated';
-const APP_STORAGE_SCOPED_ENABLED = true;
-
export const RAW_MIRROR_SCOPE_PREFIX = 'fluxer:app-storage-mirror:';
const RAW_ONLY_APP_STORAGE_KEYS: ReadonlySet<string> = new Set([
AppStorageKey.AUTH_SESSION_TOKEN,
AppStorageKey.AUTH_SESSION_USER_ID,
GATEWAY_PREBOOT_SESSION_STORAGE_KEY,
+ ZOOM_PREBOOT_MIRROR_STORAGE_KEY,
'runtimeConfig',
'AccountManager',
]);
@@ -97,9 +97,9 @@ const RAW_MIRRORED_APP_STORAGE_KEYS: ReadonlySet<string> = new Set([
...PREBOOT_MIRROR_KEYS,
...PRE_HYDRATION_APP_STORAGE_KEYS,
AppStorageKey.ACCESSIBILITY_LEGACY_STORE,
+ AppStorageKey.ACCOUNT_THEME,
AppStorageKey.MESSAGING_DRAFTS,
AppStorageKey.MESSAGING_MESSAGE_EDIT,
- AppStorageKey.THEME,
]);
let activeScope: string = UNAUTHENTICATED_APP_STORAGE_SCOPE;
@@ -125,10 +125,6 @@ function isGlobalStorageKey(key: string): boolean {
return isGlobalAppStorageKey(key) || resolveLegacyAppStorageKey(key)?.row.scope === 'global';
}
-function scopedStorageActive(): boolean {
- return scopedStorageEngaged;
-}
-
function normalizeAppStorageScope(scope: string | null | undefined): string {
if (scope == null || scope.trim().length === 0) {
return UNAUTHENTICATED_APP_STORAGE_SCOPE;
@@ -477,6 +473,7 @@ async function loadCacheForScope(scope: string): Promise<LoadedScopeCache> {
takeDeletedKeys();
if (scope !== GLOBAL_APP_STORAGE_SCOPE) {
for (const [key, entry] of await backend.load(scope)) {
+ if (isGlobalStorageKey(key)) continue;
values.set(key, entry.value);
}
takeDeletedKeys();
@@ -645,10 +642,6 @@ export function getAppStorageScope(): string {
return activeScope;
}
-export function mutationsBlocked(): boolean {
- return storageMutationsBlocked;
-}
-
export function onBeforeAppStorageScopeChange(listener: AppStorageScopeListener): () => void {
beforeScopeChangeListeners.add(listener);
return () => {
@@ -671,15 +664,10 @@ export async function initializeAppStorage(options?: {readonly scoped?: boolean}
if (initializePromise !== null) {
return initializePromise;
}
- const scoped = options?.scoped ?? APP_STORAGE_SCOPED_ENABLED;
const completion = runTransition(async () => {
if (storageInitialized) {
return;
}
- if (!scoped) {
- storageInitialized = true;
- return;
- }
scopedStorageEngaged = true;
try {
storageEventType =