A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(app): build settings preview state lazily at first use (#1935)
Hampus455681b24cc2
diff --git a/fluxer_app/src/features/user/components/modals/tabs/EmbedDebuggerTab.tsx b/fluxer_app/src/features/user/components/modals/tabs/EmbedDebuggerTab.tsxindex 668d8a435..cce7a9788 100644--- a/fluxer_app/src/features/user/components/modals/tabs/EmbedDebuggerTab.tsx+++ b/fluxer_app/src/features/user/components/modals/tabs/EmbedDebuggerTab.tsx@@ -49,29 +49,34 @@ const UNABLE_TO_UNFURL_URL_DESCRIPTOR = msg({});const EMBED_DEBUGGER_PREVIEW_CHANNEL_ID = '0';-const EMBED_DEBUGGER_PREVIEW_CHANNEL = new Channel({- id: EMBED_DEBUGGER_PREVIEW_CHANNEL_ID,- type: ChannelTypes.DM_PERSONAL_NOTES,- name: undefined,- topic: null,- url: null,- icon: null,- owner_id: null,- last_message_id: null,- last_pin_timestamp: null,- recipients: undefined,- parent_id: null,- bitrate: null,- user_limit: null,- voice_connection_limit: null,- rtc_region: null,- nsfw: false,- nsfw_override: null,- content_warning_level: 0,- content_warning_text: null,- rate_limit_per_user: 0,- nicks: {},-});+let embedDebuggerPreviewChannel: Channel | null = null;++function getEmbedDebuggerPreviewChannel(): Channel {+ embedDebuggerPreviewChannel ??= new Channel({+ id: EMBED_DEBUGGER_PREVIEW_CHANNEL_ID,+ type: ChannelTypes.DM_PERSONAL_NOTES,+ name: undefined,+ topic: null,+ url: null,+ icon: null,+ owner_id: null,+ last_message_id: null,+ last_pin_timestamp: null,+ recipients: undefined,+ parent_id: null,+ bitrate: null,+ user_limit: null,+ voice_connection_limit: null,+ rtc_region: null,+ nsfw: false,+ nsfw_override: null,+ content_warning_level: 0,+ content_warning_text: null,+ rate_limit_per_user: 0,+ nicks: {},+ });+ return embedDebuggerPreviewChannel;+}function withPreviewAuthorFallback<T extends EmbedAuthorResponse | null | undefined>(author: T): T {if (!author || author.proxy_icon_url || !author.icon_url) return author;@@ -171,7 +176,7 @@ const EmbedJsonCodeBlock: React.FC<{json: string}> = ({json}) => {const EmbedDebuggerPreview: React.FC<{message: Message}> = observer(({message}) => {const contextValue = useMemo(() => ({- channel: EMBED_DEBUGGER_PREVIEW_CHANNEL,+ channel: getEmbedDebuggerPreviewChannel(),message,shouldGroup: false,isHovering: false,diff --git a/fluxer_app/src/features/user/state/SyncedField.ts b/fluxer_app/src/features/user/state/SyncedField.tsindex cdf4d2e34..d0fb11d52 100644--- a/fluxer_app/src/features/user/state/SyncedField.ts+++ b/fluxer_app/src/features/user/state/SyncedField.ts@@ -223,7 +223,7 @@ export async function makeSyncedField<reaction(() => ({snapshot: getRemoteSnapshot(),- userId: SessionManager.userId,+ userId: SessionManager?.userId ?? null,hydrated: UserSettings.isHydrated(),}),({snapshot, userId, hydrated}) => {