diff --git a/frontend/app/src/components/NotFound.svelte b/frontend/app/src/components/NotFound.svelte index 54c5d3f280..cc2f73e77e 100644 --- a/frontend/app/src/components/NotFound.svelte +++ b/frontend/app/src/components/NotFound.svelte @@ -1,29 +1,35 @@ - -
-
-
-

404

- page(routeForScope($chatListScope))} - > -
+ +
+
+

404

- +
+ + + +
+ diff --git a/frontend/app/src/components/home/Home.svelte b/frontend/app/src/components/home/Home.svelte index 38ccd1db0e..67e797168a 100644 --- a/frontend/app/src/components/home/Home.svelte +++ b/frontend/app/src/components/home/Home.svelte @@ -92,6 +92,7 @@ import RightPanel from "./RightPanelWrapper.svelte"; import EditLabel from "../EditLabel.svelte"; import { i18nKey, type ResourceKey } from "../../i18n/i18n"; + import NotFound from "../NotFound.svelte"; type ViewProfileConfig = { userId: string; @@ -154,6 +155,7 @@ MakeProposal, Registering, LoggingIn, + NotFound, } let modal = ModalType.None; @@ -322,7 +324,7 @@ page.replace(routeForChatIdentifier($chatListScope.kind, preview.location)); } } else if (preview.kind === "failure") { - page.replace(routeForScope(client.getDefaultScope())); + modal = ModalType.NotFound; return; } } @@ -989,6 +991,7 @@ async function createDirectChat(chatId: DirectChatIdentifier): Promise { if (!(await client.createDirectChat(chatId))) { + modal = ModalType.NotFound; return false; } @@ -1149,6 +1152,7 @@ @@ -1158,6 +1162,8 @@ {:else if modal === ModalType.NoAccess} + {:else if modal === ModalType.NotFound} + {:else if modal === ModalType.GateCheckFailed && joining !== undefined} {:else if modal === ModalType.VerifyCredential && credentialCheck !== undefined} diff --git a/frontend/openchat-client/src/openchat.ts b/frontend/openchat-client/src/openchat.ts index 8224b0f07f..18c57043b2 100644 --- a/frontend/openchat-client/src/openchat.ts +++ b/frontend/openchat-client/src/openchat.ts @@ -362,6 +362,8 @@ import type { DiamondMembershipStatus, TranslationCorrections, TranslationCorrection, + Success, + Failure, } from "openchat-shared"; import { AuthProvider, @@ -947,28 +949,32 @@ export class OpenChat extends OpenChatAgentWorker { }); } - previewChat( - chatId: MultiUserChatIdentifier, - ): Promise<{ kind: "success" } | { kind: "failure" } | GroupMoved> { + previewChat(chatId: MultiUserChatIdentifier): Promise { switch (chatId.kind) { case "group_chat": - return this.sendRequest({ kind: "getPublicGroupSummary", chatId }).then((resp) => { - if (resp.kind === "success" && !resp.group.frozen) { - addGroupPreview(resp.group); - return { kind: "success" }; - } else if (resp.kind === "group_moved") { - return resp; - } - return { kind: "failure" }; - }); + return this.sendRequest({ kind: "getPublicGroupSummary", chatId }) + .then((resp) => { + if (resp.kind === "success" && !resp.group.frozen) { + addGroupPreview(resp.group); + return CommonResponses.success(); + } else if (resp.kind === "group_moved") { + return resp; + } + return CommonResponses.failure(); + }) + .catch(() => { + return CommonResponses.failure(); + }); case "channel": - return this.sendRequest({ kind: "getChannelSummary", chatId }).then((resp) => { - if (resp.kind === "channel") { - addGroupPreview(resp); - return { kind: "success" }; - } - return { kind: "failure" }; - }); + return this.sendRequest({ kind: "getChannelSummary", chatId }) + .then((resp) => { + if (resp.kind === "channel") { + addGroupPreview(resp); + return CommonResponses.success(); + } + return CommonResponses.failure(); + }) + .catch(() => CommonResponses.failure()); } } @@ -4417,12 +4423,14 @@ export class OpenChat extends OpenChatAgentWorker { } getUser(userId: string, allowStale = false): Promise { - return this.sendRequest({ kind: "getUser", userId, allowStale }).then((resp) => { - if (resp !== undefined) { - userStore.add(resp); - } - return resp; - }); + return this.sendRequest({ kind: "getUser", userId, allowStale }) + .then((resp) => { + if (resp !== undefined) { + userStore.add(resp); + } + return resp; + }) + .catch(() => undefined); } getUserStatus(userId: string, now: number): Promise {