Fix issues when saving the notification providers

This commit is contained in:
LASER-Yi 2023-06-18 20:41:55 +08:00
parent 30a17a0c67
commit 374e4bec87
No known key found for this signature in database
2 changed files with 8 additions and 3 deletions

View File

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

View File

@ -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 stagedValue = useStagedValues();
@ -93,9 +97,9 @@ export function useUpdateArray<T>(key: string, compare: keyof T) {
if (key in stagedValue) {
return stagedValue[key];
} else {
return [];
return current;
}
}, [key, stagedValue]);
}, [key, stagedValue, current]);
return useCallback(
(v: T, hook?: HookType) => {