mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
fix(app): build settings preview state lazily at first use (#1935)
This commit is contained in:
1 parent
14e63085dd
commit
455681b24c
2 files changed
+30
-25
No files matched your search
@@ -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,
|
||||
|
||||
@@ -223,7 +223,7 @@ export async function makeSyncedField<
|
||||
reaction(
|
||||
() => ({
|
||||
snapshot: getRemoteSnapshot(),
|
||||
userId: SessionManager.userId,
|
||||
userId: SessionManager?.userId ?? null,
|
||||
hydrated: UserSettings.isHydrated(),
|
||||
}),
|
||||
({snapshot, userId, hydrated}) => {
|
||||
|
||||
Reference in new issue
Block a user