|
@@ -13,7 +13,7 @@ import {
|
|
|
} from '@models';
|
|
|
import {useQuery} from '@tanstack/react-query';
|
|
|
import {useLatest} from 'ahooks';
|
|
|
-import {useMemo, useState} from 'react';
|
|
|
+import {useEffect, useMemo, useState} from 'react';
|
|
|
import {debounce} from 'lodash-es';
|
|
|
|
|
|
type Options<T extends {id: number | string}, P extends unknown[]> = {
|
|
@@ -66,14 +66,21 @@ function useQueryOptions<T extends {id: number | string}, P extends unknown[]>(
|
|
|
export function useStorageOptions(
|
|
|
addAll = false,
|
|
|
findValue?: (state: StorageListData) => string,
|
|
|
- options: {id?: string} = {},
|
|
|
+ options?: {id: string; clear: () => void},
|
|
|
) {
|
|
|
+ useEffect(
|
|
|
+ function () {
|
|
|
+ options?.clear();
|
|
|
+ },
|
|
|
+ [options?.clear, options?.id],
|
|
|
+ );
|
|
|
+
|
|
|
return useQueryOptions({
|
|
|
fn: getAllStorage,
|
|
|
findName: state => state.storageLocationName,
|
|
|
addAll,
|
|
|
findValue,
|
|
|
- params: [options.id ?? ''],
|
|
|
+ params: [options?.id ?? ''],
|
|
|
});
|
|
|
}
|
|
|
|