Skip to content

Commit 91cc07e

Browse files
author
Mishig
authored
[Assistants settings] Fix freezing (#830)
1 parent 7c4d92a commit 91cc07e

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/routes/settings/assistants/[assistantId]/+page.server.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ import { PUBLIC_ORIGIN, PUBLIC_SHARE_PREFIX } from "$env/static/public";
77
import { WEBHOOK_URL_REPORT_ASSISTANT } from "$env/static/private";
88
import { z } from "zod";
99
import type { Assistant } from "$lib/types/Assistant";
10+
11+
export async function load({ params }) {
12+
const assistant = await collections.assistants.findOne({
13+
_id: new ObjectId(params.assistantId),
14+
});
15+
16+
if (!assistant) {
17+
throw redirect(302, `${base}/assistant/${params.assistantId}`);
18+
}
19+
20+
return { assistant: JSON.parse(JSON.stringify(assistant)) };
21+
}
22+
1023
async function assistantOnlyIfAuthor(locals: App.Locals, assistantId?: string) {
1124
const assistant = await collections.assistants.findOne({ _id: new ObjectId(assistantId) });
1225

src/routes/settings/assistants/[assistantId]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
export let data: PageData;
1818
19-
$: assistant = data.assistants.find((el) => el._id.toString() === $page.params.assistantId);
19+
$: assistant = data.assistant;
2020
2121
const settings = useSettingsStore();
2222

src/routes/settings/assistants/[assistantId]/+page.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)