diff --git a/src/hooks/use-update-chunk-list.ts b/src/hooks/use-update-chunk-list.ts index d5c5dcd1..03baf203 100644 --- a/src/hooks/use-update-chunk-list.ts +++ b/src/hooks/use-update-chunk-list.ts @@ -89,6 +89,10 @@ export function useUpdateChunkedList(options: { ...cacheDataListRef.current ].slice(0, limit); + options.setDataList?.([...cacheDataListRef.current], { + createdIds: newDataList.map((item) => item.id) + }); + options.onCreate?.(latestCreateList); } diff --git a/src/hooks/use-watch-list.ts b/src/hooks/use-watch-list.ts index 2ff3b2e6..b45886d2 100644 --- a/src/hooks/use-watch-list.ts +++ b/src/hooks/use-watch-list.ts @@ -55,7 +55,7 @@ export default function useWatchList>(API: string) { cacheWatchDataListRef.current = cacheWatchDataListRef.current.filter( (item) => item.id !== id ); - setWatchDataList(cacheWatchDataListRef.current); + setWatchDataList(() => cacheWatchDataListRef.current); }; const getAllDataList = useMemoizedFn(async () => { @@ -63,8 +63,7 @@ export default function useWatchList>(API: string) { listRequestTokenRef.current?.cancel?.(); listRequestTokenRef.current = createAxiosToken(); const params = { - page: 1, - perPage: 100 + page: -1 }; const res: any = await queryAllDataList(params, { token: listRequestTokenRef.current.token @@ -86,6 +85,7 @@ export default function useWatchList>(API: string) { return { watchDataList, + setWatchDataList, deleteItemFromCache: handleDeleteItemFromCache }; } diff --git a/src/pages/model-routes/index.tsx b/src/pages/model-routes/index.tsx index 999c5311..087f326f 100644 --- a/src/pages/model-routes/index.tsx +++ b/src/pages/model-routes/index.tsx @@ -98,7 +98,7 @@ const ModelRoutes: React.FC = () => { API: MODEL_ROUTES, contentForDelete: 'menu.models.routes' }); - const { watchDataList: allRouteTargets, deleteItemFromCache } = + const { watchDataList, setWatchDataList, deleteItemFromCache } = useWatchList(MODEL_ROUTE_TARGETS); const [expandAtom] = useAtom(expandKeysAtom); const { @@ -128,6 +128,8 @@ const ModelRoutes: React.FC = () => { ); const [modelList, setModelsList] = useState[]>([]); + console.log('dataSource', dataSource); + useEffect(() => { const fetchModels = async () => { try { @@ -356,7 +358,7 @@ const ModelRoutes: React.FC = () => { > @@ -429,11 +431,6 @@ const ModelRoutes: React.FC = () => { onClose={closeViewAPIInfo} > - {/* One mount per registered action. Each mount calls its - entry's `useCreate` (single hook per component, so iterating - the plugin list doesn't violate the Rules of Hooks), - renders the form, and registers its controller so dropdown - clicks can dispatch to it. */} {configActions.map((action) => ( { onOk={handleConfigActionOk} /> ))} - {/* Page-level data lifecycle for plugin-contributed extra - columns. Receives the current list of visible route ids so - the plugin can bulk-fetch their per-user defaults in one - call (used by the quota-default column cells); `refreshToken` - bumps after a per-row save so derived page data refetches - even when the row set is unchanged. Renders nothing when no - plugin is registered. */} );