MCPcopy
hub / github.com/mifi/lossless-cut / safeSetConfig

Function safeSetConfig

src/renderer/src/hooks/useUserSettingsRoot.ts:20–35  ·  view source on GitHub ↗
(keyValue: Record<T, Config[T]>)

Source from the content-addressed store, hash-verified

18 const firstUpdateRef = useRef(true);
19
20 function safeSetConfig<T extends keyof Config>(keyValue: Record<T, Config[T]>) {
21 const entry = Object.entries(keyValue)[0]!;
22 const key = entry[0] as T;
23 const value = entry[1] as Config[T];
24
25 // Prevent flood-saving all config during mount
26 if (firstUpdateRef.current) return;
27
28 if (isDev) console.log('save', key, value);
29 try {
30 configStore.set(key, value);
31 } catch (err) {
32 console.error('Failed to set config', key, err);
33 errorToast(i18n.t('Unable to save your preferences. Try to disable any anti-virus'));
34 }
35 }
36
37 function safeGetConfig<T extends keyof Config>(key: T) {
38 const rawVal = configStore.get(key);

Callers 1

useUserSettingsRootFunction · 0.85

Calls 1

errorToastFunction · 0.90

Tested by

no test coverage detected