refactor: use api client for delete follow of assistant
Browse files
src/routes/settings/(nav)/+layout.svelte
CHANGED
|
@@ -18,6 +18,7 @@
|
|
| 18 |
import { debounce } from "$lib/utils/debounce";
|
| 19 |
|
| 20 |
import { fly } from "svelte/transition";
|
|
|
|
| 21 |
|
| 22 |
interface Props {
|
| 23 |
data: LayoutData;
|
|
@@ -30,6 +31,8 @@
|
|
| 30 |
let assistantsSection: HTMLHeadingElement | undefined = $state();
|
| 31 |
let showContent: boolean = $state(false);
|
| 32 |
|
|
|
|
|
|
|
| 33 |
function checkDesktopRedirect() {
|
| 34 |
if (
|
| 35 |
browser &&
|
|
@@ -247,20 +250,23 @@
|
|
| 247 |
]}
|
| 248 |
onclick={(event) => {
|
| 249 |
event.stopPropagation();
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
|
|
|
|
|
|
|
|
|
| 254 |
if (assistant._id.toString() === page.params.assistantId) {
|
| 255 |
goto(`${base}/settings`, { invalidateAll: true });
|
| 256 |
} else {
|
| 257 |
invalidateAll();
|
| 258 |
}
|
| 259 |
-
}
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
}}
|
| 265 |
>
|
| 266 |
<CarbonClose class="size-4 text-gray-500" />
|
|
|
|
| 18 |
import { debounce } from "$lib/utils/debounce";
|
| 19 |
|
| 20 |
import { fly } from "svelte/transition";
|
| 21 |
+
import { throwOnError, useAPIClient } from "$lib/APIClient";
|
| 22 |
|
| 23 |
interface Props {
|
| 24 |
data: LayoutData;
|
|
|
|
| 31 |
let assistantsSection: HTMLHeadingElement | undefined = $state();
|
| 32 |
let showContent: boolean = $state(false);
|
| 33 |
|
| 34 |
+
const client = useAPIClient();
|
| 35 |
+
|
| 36 |
function checkDesktopRedirect() {
|
| 37 |
if (
|
| 38 |
browser &&
|
|
|
|
| 250 |
]}
|
| 251 |
onclick={(event) => {
|
| 252 |
event.stopPropagation();
|
| 253 |
+
client
|
| 254 |
+
.assistants({
|
| 255 |
+
id: assistant._id,
|
| 256 |
+
})
|
| 257 |
+
.follow.delete()
|
| 258 |
+
.then(throwOnError)
|
| 259 |
+
.then(() => {
|
| 260 |
if (assistant._id.toString() === page.params.assistantId) {
|
| 261 |
goto(`${base}/settings`, { invalidateAll: true });
|
| 262 |
} else {
|
| 263 |
invalidateAll();
|
| 264 |
}
|
| 265 |
+
})
|
| 266 |
+
.catch((err) => {
|
| 267 |
+
console.error(err);
|
| 268 |
+
$error = err.message;
|
| 269 |
+
});
|
| 270 |
}}
|
| 271 |
>
|
| 272 |
<CarbonClose class="size-4 text-gray-500" />
|