File tree Expand file tree Collapse file tree
src/routes/settings/(nav) Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 import { debounce } from " $lib/utils/debounce" ;
1919
2020 import { fly } from " svelte/transition" ;
21+ import { throwOnError , useAPIClient } from " $lib/APIClient" ;
2122
2223 interface Props {
2324 data: LayoutData ;
3031 let assistantsSection: HTMLHeadingElement | undefined = $state ();
3132 let showContent: boolean = $state (false );
3233
34+ const client = useAPIClient ();
35+
3336 function checkDesktopRedirect() {
3437 if (
3538 browser &&
247250 ]}
248251 onclick ={(event ) => {
249252 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 (() => {
254260 if (assistant ._id .toString () === page .params .assistantId ) {
255261 goto (` ${base }/settings ` , { invalidateAll: true });
256262 } else {
257263 invalidateAll ();
258264 }
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+ });
264270 }}
265271 >
266272 <CarbonClose class =" size-4 text-gray-500" />
You can’t perform that action at this time.
0 commit comments