fix(app): build settings preview state lazily at first use (#1935)

This commit is contained in:
Hampus authored and GitHub committed 2026-08-24 12:48:47 +02:00
1 parent 14e63085dd
commit 455681b24c
2 files changed
+9 -4

No files matched your search

@@ -49,7 +49,10 @@ const UNABLE_TO_UNFURL_URL_DESCRIPTOR = msg({
}); });
const EMBED_DEBUGGER_PREVIEW_CHANNEL_ID = '0'; const EMBED_DEBUGGER_PREVIEW_CHANNEL_ID = '0';
const EMBED_DEBUGGER_PREVIEW_CHANNEL = new Channel({ let embedDebuggerPreviewChannel: Channel | null = null;
function getEmbedDebuggerPreviewChannel(): Channel {
embedDebuggerPreviewChannel ??= new Channel({
id: EMBED_DEBUGGER_PREVIEW_CHANNEL_ID, id: EMBED_DEBUGGER_PREVIEW_CHANNEL_ID,
type: ChannelTypes.DM_PERSONAL_NOTES, type: ChannelTypes.DM_PERSONAL_NOTES,
name: undefined, name: undefined,
@@ -71,7 +74,9 @@ const EMBED_DEBUGGER_PREVIEW_CHANNEL = new Channel({
content_warning_text: null, content_warning_text: null,
rate_limit_per_user: 0, rate_limit_per_user: 0,
nicks: {}, nicks: {},
}); });
return embedDebuggerPreviewChannel;
}
function withPreviewAuthorFallback<T extends EmbedAuthorResponse | null | undefined>(author: T): T { function withPreviewAuthorFallback<T extends EmbedAuthorResponse | null | undefined>(author: T): T {
if (!author || author.proxy_icon_url || !author.icon_url) return author; 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 EmbedDebuggerPreview: React.FC<{message: Message}> = observer(({message}) => {
const contextValue = useMemo( const contextValue = useMemo(
() => ({ () => ({
channel: EMBED_DEBUGGER_PREVIEW_CHANNEL, channel: getEmbedDebuggerPreviewChannel(),
message, message,
shouldGroup: false, shouldGroup: false,
isHovering: false, isHovering: false,
@@ -223,7 +223,7 @@ export async function makeSyncedField<
reaction( reaction(
() => ({ () => ({
snapshot: getRemoteSnapshot(), snapshot: getRemoteSnapshot(),
userId: SessionManager.userId, userId: SessionManager?.userId ?? null,
hydrated: UserSettings.isHydrated(), hydrated: UserSettings.isHydrated(),
}), }),
({snapshot, userId, hydrated}) => { ({snapshot, userId, hydrated}) => {