sync detail

This commit is contained in:
m
2026-08-28 23:48:19 +02:00
parent bba46fa2b3
commit e43aa2d793
3 changed files with 46 additions and 58 deletions
+1 -23
View File
@@ -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);