diff --git a/src/app/components/Chat.svelte b/src/app/components/Chat.svelte index be5f02a9..4a078841 100644 --- a/src/app/components/Chat.svelte +++ b/src/app/components/Chat.svelte @@ -53,7 +53,7 @@ import ChatComposeEdit from "@app/components/ChatComposeEdit.svelte" import ChatComposeParent from "@app/components/ChatComposeParent.svelte" import ThunkToast from "@app/components/ThunkToast.svelte" - import {userSettingsValues, deriveChat} from "@app/core/state" + import {userSettingsValues, deriveChat, makeChatId} from "@app/core/state" import {pushModal} from "@app/util/modal" import {DraftKey} from "@app/util/drafts" import {makeDelete, prependParent} from "@app/core/commands" @@ -66,8 +66,9 @@ const {pubkeys, info}: Props = $props() - const chat = deriveChat(pubkeys) - const draftKey = new DraftKey<{content?: string | object}>(`dm:${$chat?.id}`) + const chatId = makeChatId(pubkeys) + const chat = deriveChat(chatId) + const draftKey = new DraftKey<{content?: string | object}>(`dm:${chatId}`) const others = remove($pubkey!, pubkeys) const missingRelayLists = $derived(others.filter(pk => !$messagingRelayListsByPubkey.has(pk))) diff --git a/src/app/core/state.ts b/src/app/core/state.ts index 0630385d..0496d655 100644 --- a/src/app/core/state.ts +++ b/src/app/core/state.ts @@ -560,11 +560,7 @@ export const chatsById = call(() => { }) }) -export const deriveChat = call(() => { - const _deriveChat = makeDeriveItem(chatsById) - - return (pubkeys: string[]) => _deriveChat(makeChatId(pubkeys)) -}) +export const deriveChat = makeDeriveItem(chatsById) export const chatSearch = derived(throttled(1500, chatsById), $chatsByPubkey => { return createSearch(