Fix issues when saving the notification providers

pull/2182/head
LASER-Yi 2 years ago
parent 30a17a0c67
commit 374e4bec87
No known key found for this signature in database

@ -123,6 +123,7 @@ export const NotificationView: FunctionComponent = () => {
const update = useUpdateArray<Settings.NotificationInfo>( const update = useUpdateArray<Settings.NotificationInfo>(
notificationsKey, notificationsKey,
notifications ?? [],
"name" "name"
); );

@ -82,7 +82,11 @@ export function useSettingValue<T>(
} }
} }
export function useUpdateArray<T>(key: string, compare: keyof T) { export function useUpdateArray<T>(
key: string,
current: Readonly<T[]>,
compare: keyof T
) {
const { setValue } = useFormActions(); const { setValue } = useFormActions();
const stagedValue = useStagedValues(); const stagedValue = useStagedValues();
@ -93,9 +97,9 @@ export function useUpdateArray<T>(key: string, compare: keyof T) {
if (key in stagedValue) { if (key in stagedValue) {
return stagedValue[key]; return stagedValue[key];
} else { } else {
return []; return current;
} }
}, [key, stagedValue]); }, [key, stagedValue, current]);
return useCallback( return useCallback(
(v: T, hook?: HookType) => { (v: T, hook?: HookType) => {

Loading…
Cancel
Save