diff --git a/apps/web/src/stores/entries.ts b/apps/web/src/stores/entries.ts index 3df5b2f..a3d0096 100644 --- a/apps/web/src/stores/entries.ts +++ b/apps/web/src/stores/entries.ts @@ -84,8 +84,7 @@ export const useEntryStore = defineStore("entries", { ); const pendingOperations = (await db.syncOperations.filter((operation) => operation.syncedAt === null).toArray()) .filter((operation) => - (operation.userId ?? operation.payload.updatedBy) === auth.user!.id - || operation.ledgerIds.some((ledgerId) => allowedLedgerIds.has(ledgerId)), + (operation.userId ?? operation.payload.updatedBy) === auth.user!.id, ); this.pendingEntryIds = [...new Set(pendingOperations.map((operation) => operation.entityId))]; this.pendingEntries = [...new Map( diff --git a/apps/web/src/stores/ledgers.ts b/apps/web/src/stores/ledgers.ts index 761d80a..fafd19d 100644 --- a/apps/web/src/stores/ledgers.ts +++ b/apps/web/src/stores/ledgers.ts @@ -55,22 +55,9 @@ export const useLedgerStore = defineStore("ledgers", { this.ledgers = serverLedgers; const allowedIds = new Set(this.ledgers.map((ledger) => ledger.id)); - const localEntries = await db.entries.toArray(); - const inaccessibleEntries = localEntries - .filter((entry) => entry.ownerId !== auth.user!.id && !entry.ledgerIds.some((ledgerId) => allowedIds.has(ledgerId))) - .map((entry) => entry.id); - const projectedEntries = localEntries - .filter((entry) => entry.ownerId !== auth.user!.id && entry.ledgerIds.some((ledgerId) => !allowedIds.has(ledgerId))) - .map((entry) => ({ ...entry, ledgerIds: entry.ledgerIds.filter((ledgerId) => allowedIds.has(ledgerId)) })); - const inaccessibleOperations = await db.syncOperations - .filter((item) => (item.userId ?? item.payload.updatedBy) !== auth.user!.id) - .primaryKeys(); - await db.transaction("rw", db.ledgers, db.entries, db.syncOperations, async () => { + await db.transaction("rw", db.ledgers, async () => { await db.ledgers.clear(); if (serverLedgers.length) await db.ledgers.bulkPut(serverLedgers); - if (projectedEntries.length) await db.entries.bulkPut(projectedEntries); - if (inaccessibleEntries.length) await db.entries.bulkDelete(inaccessibleEntries); - if (inaccessibleOperations.length) await db.syncOperations.bulkDelete(inaccessibleOperations); }); const preferenceId = currentLedgerPreferenceId(auth.user.id);