use auto sync

This commit is contained in:
m
2026-08-29 09:31:53 +02:00
parent e43aa2d793
commit 479c8ab61c
5 changed files with 327 additions and 93 deletions
+14 -1
View File
@@ -1,6 +1,6 @@
import { drizzle } from 'drizzle-orm/expo-sqlite';
import * as SQLite from 'expo-sqlite';
import { eq, like, or, and, desc, asc, sql, isNull } from 'drizzle-orm';
import { eq, like, or, and, desc, asc, sql, isNull, inArray, isNotNull } from 'drizzle-orm';
import { files, fileTags, deletedFiles, pendingActions } from './schema';
import type { Tag, PendingAction, PendingActionType, PendingActionStatus } from '../../types';
@@ -590,6 +590,19 @@ export const fileStore = {
return row?.count ?? 0;
},
countPendingSync(): number {
const d = getDb();
const row = d.select({ count: sql<number>`count(*)` }).from(files).where(
and(
or(eq(files.source, 'local'), eq(files.source, 'synced')),
isNull(files.backendId),
isNotNull(files.localUri),
inArray(files.syncStatus, ['local', 'error']),
)
).get();
return row?.count ?? 0;
},
getAllLocal(): FileRecord[] {
const d = getDb();
const rows = d.select().from(files)