Spaces:
Build error
Build error
Mishig
commited on
[Assistants settings] Fix freezing (#830)
Browse files
src/routes/settings/assistants/[assistantId]/+page.server.ts
CHANGED
@@ -7,6 +7,19 @@ import { PUBLIC_ORIGIN, PUBLIC_SHARE_PREFIX } from "$env/static/public";
|
|
7 |
import { WEBHOOK_URL_REPORT_ASSISTANT } from "$env/static/private";
|
8 |
import { z } from "zod";
|
9 |
import type { Assistant } from "$lib/types/Assistant";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
async function assistantOnlyIfAuthor(locals: App.Locals, assistantId?: string) {
|
11 |
const assistant = await collections.assistants.findOne({ _id: new ObjectId(assistantId) });
|
12 |
|
|
|
7 |
import { WEBHOOK_URL_REPORT_ASSISTANT } from "$env/static/private";
|
8 |
import { z } from "zod";
|
9 |
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 |
+
|
23 |
async function assistantOnlyIfAuthor(locals: App.Locals, assistantId?: string) {
|
24 |
const assistant = await collections.assistants.findOne({ _id: new ObjectId(assistantId) });
|
25 |
|
src/routes/settings/assistants/[assistantId]/+page.svelte
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
|
17 |
export let data: PageData;
|
18 |
|
19 |
-
$: assistant = data.
|
20 |
|
21 |
const settings = useSettingsStore();
|
22 |
|
|
|
16 |
|
17 |
export let data: PageData;
|
18 |
|
19 |
+
$: assistant = data.assistant;
|
20 |
|
21 |
const settings = useSettingsStore();
|
22 |
|
src/routes/settings/assistants/[assistantId]/+page.ts
DELETED
@@ -1,14 +0,0 @@
|
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|