mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
fix(Settings): standardize manifest fetching behavior
This commit is contained in:
parent
d7d3821c06
commit
c4514e8c3d
|
|
@ -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 (
|
||||
<SettingsLayout>
|
||||
<Head title="Maps Manager" />
|
||||
|
|
@ -215,11 +204,11 @@ export default function MapsManager(props: {
|
|||
<div className="mt-8 mb-6 flex items-center justify-between">
|
||||
<StyledSectionHeader title="Curated Map Regions" className="!mb-0" />
|
||||
<StyledButton
|
||||
onClick={() => fetchLatestCollections.mutate()}
|
||||
disabled={fetchLatestCollections.isPending}
|
||||
onClick={() => refreshManifests.mutate()}
|
||||
disabled={refreshManifests.isPending}
|
||||
icon="IconRefresh"
|
||||
>
|
||||
Get Latest Collections from GitHub
|
||||
Force Refresh Collections
|
||||
</StyledButton>
|
||||
</div>
|
||||
<div className="!mt-4 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
/>
|
||||
)}
|
||||
<StyledSectionHeader title="Curated Content" className="mt-8 !mb-4" />
|
||||
|
||||
<div className="mt-8 mb-6 flex items-center justify-between">
|
||||
<StyledSectionHeader title="Curated Content" className="!mb-0" />
|
||||
<StyledButton
|
||||
onClick={() => refreshManifests.mutate()}
|
||||
disabled={refreshManifests.isPending || !isOnline}
|
||||
icon="IconRefresh"
|
||||
>
|
||||
Force Refresh Collections
|
||||
</StyledButton>
|
||||
</div>
|
||||
|
||||
{/* Wikipedia Selector */}
|
||||
{isLoadingWikipedia ? (
|
||||
<div className="mt-8 bg-white rounded-lg border border-gray-200 p-6">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user