mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 21:04:59 +00:00
feat(storage): add archive storage support for assets
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { client } from '@/ui/api/client'
|
||||
|
||||
export interface ArchiveConfig {
|
||||
archiveStorageEnabled: boolean
|
||||
isLoading: boolean
|
||||
}
|
||||
|
||||
export function useArchiveConfig(): ArchiveConfig {
|
||||
const { data, isLoading } = useQuery({
|
||||
queryKey: ['signup-info'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api['signup-info'].$get()
|
||||
if (!res.ok) {
|
||||
return { initialized: true, demoMode: false, archiveStorageEnabled: false }
|
||||
}
|
||||
return (await res.json()) as {
|
||||
initialized?: boolean
|
||||
demoMode?: boolean
|
||||
archiveStorageEnabled?: boolean
|
||||
}
|
||||
},
|
||||
staleTime: 5 * 60 * 1000,
|
||||
})
|
||||
|
||||
return {
|
||||
archiveStorageEnabled: Boolean(data?.archiveStorageEnabled),
|
||||
isLoading,
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,11 @@ export function useBatchFileStatus({ teamId, items }: UseBatchFileStatusOptions)
|
||||
return items
|
||||
.filter((item) => {
|
||||
if (!item.id || (item.type !== 'file' && item.type !== 'version_stack')) return false
|
||||
const isUploadedOrProcessing = item.status === 'uploaded' || item.status === 'processing'
|
||||
const isUploadedOrProcessing =
|
||||
item.status === 'uploaded' ||
|
||||
item.status === 'processing' ||
|
||||
item.status === 'archiving' ||
|
||||
item.status === 'restoring'
|
||||
const progress = fileProgress[item.id]
|
||||
const isUploadCompleted =
|
||||
item.status === 'uploading' &&
|
||||
@@ -71,12 +75,20 @@ export function useBatchFileStatus({ teamId, items }: UseBatchFileStatusOptions)
|
||||
}
|
||||
|
||||
const anyFinished = assets.some(
|
||||
(a) => a.status === 'processed' || a.status === 'failed' || a.status === 'error',
|
||||
(a) =>
|
||||
a.status === 'processed' ||
|
||||
a.status === 'archived' ||
|
||||
a.status === 'failed' ||
|
||||
a.status === 'error',
|
||||
)
|
||||
const allFinished =
|
||||
assets.length > 0 &&
|
||||
assets.every(
|
||||
(a) => a.status === 'processed' || a.status === 'failed' || a.status === 'error',
|
||||
(a) =>
|
||||
a.status === 'processed' ||
|
||||
a.status === 'archived' ||
|
||||
a.status === 'failed' ||
|
||||
a.status === 'error',
|
||||
)
|
||||
|
||||
const now = Date.now()
|
||||
|
||||
Reference in New Issue
Block a user