@mdguggenbichler/slugbase-core 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -65,9 +65,12 @@ export default function AdminAI() {
|
|
|
65
65
|
}
|
|
66
66
|
}, [showToast, t, adminAiOnlyToggle]);
|
|
67
67
|
|
|
68
|
+
// Run initial load once on mount only. Re-running when loadSettings identity changes
|
|
69
|
+
// (e.g. from i18n t) caused repeated API calls and infinite toasts on error.
|
|
68
70
|
useEffect(() => {
|
|
69
71
|
loadSettings();
|
|
70
|
-
|
|
72
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
73
|
+
}, []);
|
|
71
74
|
|
|
72
75
|
const loadModels = useCallback(async () => {
|
|
73
76
|
setModelsLoading(true);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
1
2
|
import { toast as sonnerToast } from 'sonner';
|
|
2
3
|
import { Toaster } from './sonner';
|
|
3
4
|
|
|
@@ -11,28 +12,27 @@ export interface Toast {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export function useToast() {
|
|
14
|
-
const showToast = (
|
|
15
|
-
message: string,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
15
|
+
const showToast = useCallback(
|
|
16
|
+
(message: string, variant: ToastVariant = 'info', duration = 3000) => {
|
|
17
|
+
const options = duration > 0 ? { duration } : { duration: Infinity };
|
|
18
|
+
switch (variant) {
|
|
19
|
+
case 'success':
|
|
20
|
+
sonnerToast.success(message, options);
|
|
21
|
+
break;
|
|
22
|
+
case 'error':
|
|
23
|
+
sonnerToast.error(message, options);
|
|
24
|
+
break;
|
|
25
|
+
case 'warning':
|
|
26
|
+
sonnerToast.warning(message, options);
|
|
27
|
+
break;
|
|
28
|
+
case 'info':
|
|
29
|
+
default:
|
|
30
|
+
sonnerToast.info(message, options);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
[]
|
|
35
|
+
);
|
|
36
36
|
|
|
37
37
|
return { showToast };
|
|
38
38
|
}
|