File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed
src/routes/settings/(nav) Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change 18
18
import { debounce } from " $lib/utils/debounce" ;
19
19
20
20
import { fly } from " svelte/transition" ;
21
+ import { throwOnError , useAPIClient } from " $lib/APIClient" ;
21
22
22
23
interface Props {
23
24
data: LayoutData ;
30
31
let assistantsSection: HTMLHeadingElement | undefined = $state ();
31
32
let showContent: boolean = $state (false );
32
33
34
+ const client = useAPIClient ();
35
+
33
36
function checkDesktopRedirect() {
34
37
if (
35
38
browser &&
247
250
]}
248
251
onclick ={(event ) => {
249
252
event .stopPropagation ();
250
- fetch (` ${base }/api/assistant/${assistant ._id }/subscribe ` , {
251
- method: " DELETE" ,
252
- }).then ((r ) => {
253
- if (r .ok ) {
253
+ client
254
+ .assistants ({
255
+ id: assistant ._id ,
256
+ })
257
+ .follow .delete ()
258
+ .then (throwOnError )
259
+ .then (() => {
254
260
if (assistant ._id .toString () === page .params .assistantId ) {
255
261
goto (` ${base }/settings ` , { invalidateAll: true });
256
262
} else {
257
263
invalidateAll ();
258
264
}
259
- } else {
260
- console . error ( r );
261
- $error = r . statusText ;
262
- }
263
- });
265
+ })
266
+ . catch (( err ) => {
267
+ console . error ( err ) ;
268
+ $error = err . message ;
269
+ });
264
270
}}
265
271
>
266
272
<CarbonClose class =" size-4 text-gray-500" />
You can’t perform that action at this time.
0 commit comments