From c4514e8c3dd16adc7c68e88719fd3636e3a9adea Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Wed, 11 Feb 2026 16:13:21 -0800 Subject: [PATCH] fix(Settings): standardize manifest fetching behavior --- admin/inertia/pages/settings/maps.tsx | 25 ++++++------------- .../pages/settings/zim/remote-explorer.tsx | 14 +++++++++-- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/admin/inertia/pages/settings/maps.tsx b/admin/inertia/pages/settings/maps.tsx index d411b39..220ed41 100644 --- a/admin/inertia/pages/settings/maps.tsx +++ b/admin/inertia/pages/settings/maps.tsx @@ -6,7 +6,7 @@ import { useModals } from '~/context/ModalContext' import StyledModal from '~/components/StyledModal' import { FileEntry } from '../../../types/files' import { useNotifications } from '~/context/NotificationContext' -import { useEffect, useState } from 'react' +import { useState } from 'react' import api from '~/lib/api' import DownloadURLModal from '~/components/DownloadURLModal' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' @@ -161,28 +161,17 @@ export default function MapsManager(props: { ) } - const fetchLatestCollections = useMutation({ - mutationFn: () => api.fetchLatestMapCollections(), + const refreshManifests = useMutation({ + mutationFn: () => api.refreshManifests(), onSuccess: () => { addNotification({ - message: 'Successfully fetched the latest map collections.', + message: 'Successfully refreshed map collections.', type: 'success', }) queryClient.invalidateQueries({ queryKey: [CURATED_COLLECTIONS_KEY] }) }, }) - // Auto-fetch latest collections if the list is empty - useEffect(() => { - if ( - curatedCollections && - curatedCollections.length === 0 && - !fetchLatestCollections.isPending - ) { - fetchLatestCollections.mutate() - } - }, [curatedCollections, fetchLatestCollections]) - return ( @@ -215,11 +204,11 @@ export default function MapsManager(props: {
fetchLatestCollections.mutate()} - disabled={fetchLatestCollections.isPending} + onClick={() => refreshManifests.mutate()} + disabled={refreshManifests.isPending} icon="IconRefresh" > - Get Latest Collections from GitHub + Force Refresh Collections
diff --git a/admin/inertia/pages/settings/zim/remote-explorer.tsx b/admin/inertia/pages/settings/zim/remote-explorer.tsx index d5dfc5a..f3df464 100644 --- a/admin/inertia/pages/settings/zim/remote-explorer.tsx +++ b/admin/inertia/pages/settings/zim/remote-explorer.tsx @@ -265,6 +265,7 @@ export default function ZimRemoteExplorer() { type: 'success', }) queryClient.invalidateQueries({ queryKey: [CURATED_CATEGORIES_KEY] }) + queryClient.invalidateQueries({ queryKey: [WIKIPEDIA_STATE_KEY] }) }, }) @@ -296,8 +297,17 @@ export default function ZimRemoteExplorer() { className="!mt-6" /> )} - - +
+ + refreshManifests.mutate()} + disabled={refreshManifests.isPending || !isOnline} + icon="IconRefresh" + > + Force Refresh Collections + +
+ {/* Wikipedia Selector */} {isLoadingWikipedia ? (