Skip to content

Commit b63aabe

Browse files
author
Mishig
authored
Revert "[Assistants settings] Fix freezing (#830)" (#831)
This reverts commit 91cc07e.
1 parent 91cc07e commit b63aabe

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,6 @@ 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-
2310
async function assistantOnlyIfAuthor(locals: App.Locals, assistantId?: string) {
2411
const assistant = await collections.assistants.findOne({ _id: new ObjectId(assistantId) });
2512

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.assistant;
19+
$: assistant = data.assistants.find((el) => el._id.toString() === $page.params.assistantId);
2020
2121
const settings = useSettingsStore();
2222
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { base } from "$app/paths";
2+
import { redirect } from "@sveltejs/kit";
3+
4+
export async function load({ parent, params }) {
5+
const data = await parent();
6+
7+
const assistant = data.settings.assistants.find((id) => id === params.assistantId);
8+
9+
if (!assistant) {
10+
throw redirect(302, `${base}/assistant/${params.assistantId}`);
11+
}
12+
13+
return data;
14+
}

0 commit comments

Comments
 (0)