sync detail
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { createMMKV } from 'react-native-mmkv';
|
||||
import { fileStore } from '../services/fileStore';
|
||||
import { safDirectory } from '../services/safDirectory';
|
||||
import { useDeviceFiles } from './useDeviceFiles';
|
||||
|
||||
const syncStateStorage = createMMKV({ id: 'vaultdrop-sync-state' });
|
||||
|
||||
@@ -17,35 +15,15 @@ export function setIsSyncing(value: boolean) {
|
||||
export function useSyncQueue() {
|
||||
const [pendingCount, setPendingCount] = useState(0);
|
||||
const [isSyncing, setIsSyncingState] = useState(() => getIsSyncing());
|
||||
const { folders } = useDeviceFiles();
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
const globalMode = safDirectory.getGlobalSyncMode();
|
||||
|
||||
if (globalMode === 'off') {
|
||||
setPendingCount(0);
|
||||
setIsSyncingState(getIsSyncing());
|
||||
return;
|
||||
}
|
||||
|
||||
const allFolders = safDirectory.getAll();
|
||||
const autoFolderIds = new Set(
|
||||
allFolders.filter((f) => f.syncMode === 'auto').map((f) => f.id)
|
||||
);
|
||||
|
||||
const registry = fileStore.getAllLocal();
|
||||
let count = 0;
|
||||
|
||||
for (const entry of registry) {
|
||||
if (entry.backendId || !entry.localUri) continue;
|
||||
if (entry.syncStatus !== 'local' && entry.syncStatus !== 'error') continue;
|
||||
if (globalMode === 'auto') {
|
||||
count++;
|
||||
} else {
|
||||
// mode manuel : uniquement les fichiers des dossiers en mode auto
|
||||
if (!entry.parentResourceId || !autoFolderIds.has(entry.parentResourceId)) continue;
|
||||
count++;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
setPendingCount(count);
|
||||
|
||||
Reference in New Issue
Block a user