Skip to content

Open source personal finance application

chore: remove redundant inline comments

Ilya Komichev0d386d89bbc9
diff --git a/app/components/app/useInitApp.ts b/app/components/app/useInitApp.ts
index 70bebba0..83ec9bb1 100644
--- a/app/components/app/useInitApp.ts
+++ b/app/components/app/useInitApp.ts
@@ -66,8 +66,6 @@ export function useInitApp() {
}
function clearLocalData() {
- // Block all persist operations — prevents in-flight store inits, mutation callbacks,
- // and debounced persists from re-writing data after cleanup.
blockPersist()
categoriesStore.setCategories(null)
@@ -75,8 +73,6 @@ export function useInitApp() {
walletsStore.setWallets(null)
userStore.setUser(null)
- // Clear cached data from localforage to prevent data leaks on shared devices.
- // The offline queue is intentionally preserved — it has its own userId ownership check.
const offlineKeys = new Set([STORAGE_KEYS.offlineQueue, STORAGE_KEYS.offlineQueueUserId])
for (const key of Object.values(STORAGE_KEYS)) {
if (!offlineKeys.has(key))
@@ -85,20 +81,14 @@ export function useInitApp() {
}
async function loadDataFromDB() {
- // Unblock persists — may have been blocked by a prior clearLocalData
unblockPersist()
- // Wait for Convex auth token to be fetched so queries run authenticated.
- // Without this, queries can fire before setAuth's token fetch completes.
const { $waitForConvexAuth } = useNuxtApp()
await ($waitForConvexAuth as () => Promise<void>)()
- // No authenticated user — skip data loading and replay to avoid
- // overwriting cached stores with empty data or replaying without auth.
if (!userStore.uid)
return
- // Set in-memory userId for queue ownership stamping during pushes
setOfflineQueueUserId(userStore.uid)
isDbLoading.value = true
diff --git a/app/components/categories/useCategoriesStore.ts b/app/components/categories/useCategoriesStore.ts
index dd26a07d..a3a31366 100644
--- a/app/components/categories/useCategoriesStore.ts
+++ b/app/components/categories/useCategoriesStore.ts
@@ -125,7 +125,6 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStore
latestDateByCategory.set(categoryId, trn.date)
}
- // Filter valid categories and pick top N by most recent usage
const sortedEntries = [...latestDateByCategory.entries()].toSorted(([, dateA], [, dateB]) => dateB - dateA)
const recentIds: CategoryId[] = []
@@ -230,7 +229,6 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStore
// Frontend IDs are always treated as new creates (server generates real ID)
const isExisting = !isLocalId(id) && items.value && id in items.value
- // Optimistic UI
applyOptimisticUpdate(id, values, isUpdateChildCategoriesColor, categoryChildIds)
if (!pushSaveOp({ entity: 'categories', id, isDemo: !!isDemo.value, isExisting: !!isExisting, values }))
@@ -273,19 +271,16 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStore
if (id === 'transfer' || id === 'adjustment')
return
- // Optimistic UI
const categories = { ...items.value }
delete categories[id]
setCategories(categories)
- // Optimistic: remove trns from store immediately (backend cascade handles actual deletion)
if (trnsIds?.length)
trnsStore.removeTrnsFromStore(trnsIds)
if (!pushDeleteOp({ entity: 'categories', id, isDemo: !!isDemo.value }))
return
- // Fire-and-forget mutation, cleanup on success
const { api, client } = useConvexClientWithApi()
return handleMutationResult({
action: 'delete',
diff --git a/app/components/demo/useDemo.ts b/app/components/demo/useDemo.ts
index beaca254..0eacf67c 100644
--- a/app/components/demo/useDemo.ts
+++ b/app/components/demo/useDemo.ts
@@ -35,17 +35,14 @@ function weightedPick<T extends { weight: number }>(rules: T[]): T {
return rules.at(-1)!
}
-/** Random integer in [min, max]. */
function randInt(min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1)) + min
}
-/** Random item from array. */
function randItem<T>(arr: T[]): T {
return arr[Math.floor(Math.random() * arr.length)]!
}
-/** Round to nearest 10. */
function roundAmount(n: number): number {
return Math.round(n / 10) * 10
}
diff --git a/app/components/offline/helpers.ts b/app/components/offline/helpers.ts
index 84294f00..52658084 100644
--- a/app/components/offline/helpers.ts
+++ b/app/components/offline/helpers.ts
@@ -10,10 +10,6 @@ const QUEUE_USER_KEY = STORAGE_KEYS.offlineQueueUserId
const logger = createLogger('offline')
-/**
- * Module-level userId for stamping queue ownership at push time.
- * Set via setOfflineQueueUserId() during app init / replay.
- */
let _currentUserId: string | null = null
export function setOfflineQueueUserId(userId: string | null): void {
@@ -50,8 +46,6 @@ async function writeQueue(queue: OfflineOp[]): Promise<void> {
}
/**
- * Add operation to the unified offline queue with collapsing.
- *
* Collapsing rules (matching by entity + id):
* | Existing | New | Result |
* |----------|--------|-------------------------------------|
@@ -60,7 +54,7 @@ async function writeQueue(queue: OfflineOp[]): Promise<void> {
* | update | update | update with merged data |
* | update | delete | replace update with delete |
* | delete | * | ignore new (delete is terminal) |
- * | — | * | append as-is |
+ * | - | * | append as-is |
*/
let writeChain = Promise.resolve()
@@ -70,7 +64,6 @@ export function pushOfflineOp(op: OfflineOpInput): Promise<void> {
}
async function pushOfflineOpImpl(op: OfflineOpInput): Promise<void> {
- // Ensure queue ownership is stamped on first push
if (_currentUserId) {
const storedUserId = await localforage.getItem<string>(QUEUE_USER_KEY)
if (!storedUserId)
@@ -90,7 +83,6 @@ async function pushOfflineOpImpl(op: OfflineOpInput): Promise<void> {
const existing = queue[existingIdx]!
- // delete is terminal — ignore any new operation
if (existing.type === 'delete') {
logger.log(`skip ${op.type} (already deleted): ${op.entity}/${op.id}`)
return
@@ -98,12 +90,10 @@ async function pushOfflineOpImpl(op: OfflineOpInput): Promise<void> {
if (op.type === 'delete') {
if (existing.type === 'create') {
- // Never reached server — remove both
queue.splice(existingIdx, 1)
logger.log(`collapsed create+delete (removed): ${op.entity}/${op.id}`)
}
else {
- // update → delete: replace
queue[existingIdx] = { ...op, timestamp: Date.now() } as OfflineOp
logger.log(`collapsed update→delete: ${op.entity}/${op.id}`)
}
@@ -111,8 +101,6 @@ async function pushOfflineOpImpl(op: OfflineOpInput): Promise<void> {
return
}
- // create + update → create with merged data
- // update + update → update with merged data
queue[existingIdx] = {
...existing,
data: { ...existing.data, ...op.data },
@@ -122,10 +110,6 @@ async function pushOfflineOpImpl(op: OfflineOpInput): Promise<void> {
logger.log(`collapsed ${existing.type}+${op.type}: ${op.entity}/${op.id}`)
}
-/**
- * Remove all operations for entity+id (after successful mutation).
- * Serialized through writeChain to prevent race conditions with pushOfflineOp.
- */
export function removeOfflineOp(entity: EntityType, id: string): Promise<void> {
writeChain = writeChain.then(() => removeOfflineOpImpl(entity, id), () => removeOfflineOpImpl(entity, id))
return writeChain
@@ -140,10 +124,6 @@ async function removeOfflineOpImpl(entity: EntityType, id: string): Promise<void
}
}
-/**
- * Remove all operations for entity + multiple ids in a single read/write.
- * Serialized through writeChain to prevent race conditions.
- */
export function removeOfflineOps(entity: EntityType, ids: string[]): Promise<void> {
writeChain = writeChain.then(() => removeOfflineOpsImpl(entity, ids), () => removeOfflineOpsImpl(entity, ids))
return writeChain
@@ -159,10 +139,6 @@ async function removeOfflineOpsImpl(entity: EntityType, ids: string[]): Promise<
}
}
-/**
- * Remove a specific operation matching entity+id+type.
- * Serialized through writeChain to prevent race conditions.
- */
export function removeOfflineOpByType(entity: EntityType, id: string, type: OfflineOp['type']): Promise<void> {
writeChain = writeChain.then(() => removeOfflineOpByTypeImpl(entity, id, type), () => removeOfflineOpByTypeImpl(entity, id, type))
return writeChain
@@ -177,39 +153,23 @@ async function removeOfflineOpByTypeImpl(entity: EntityType, id: string, type: O
}
}
-/**
- * Get all operations in order (for replay).
- */
export async function getAllOfflineOps(): Promise<OfflineOp[]> {
return readQueue()
}
-/**
- * Get operations for a specific entity (for init merge).
- */
export async function getOfflineOpsByEntity(entity: EntityType): Promise<OfflineOp[]> {
const queue = await readQueue()
return queue.filter(o => o.entity === entity)
}
-/**
- * Get the userId associated with the current offline queue.
- */
export async function getQueueUserId(): Promise<string | null> {
return localforage.getItem<string>(QUEUE_USER_KEY)
}
-/**
- * Set the userId associated with the current offline queue.
- */
export async function setQueueUserId(userId: string): Promise<void> {
await localforage.setItem(QUEUE_USER_KEY, userId)
}
-/**
- * Clear the entire offline queue (logout or user mismatch).
- * Serialized through writeChain to prevent race conditions with pushOfflineOp.
- */
export function clearOfflineQueue(): Promise<void> {
writeChain = writeChain.then(() => clearOfflineQueueImpl(), () => clearOfflineQueueImpl())
return writeChain
diff --git a/app/components/offline/replay.ts b/app/components/offline/replay.ts
index a79505f2..da325ead 100644
--- a/app/components/offline/replay.ts
+++ b/app/components/offline/replay.ts
@@ -24,7 +24,6 @@ export async function replayOfflineQueue(): Promise<void> {
const userStore = useUserStore()
const currentUserId = userStore.uid
- // Verify queue ownership — don't replay another user's queue
try {
const queueUserId = await getQueueUserId()
if (queueUserId && queueUserId !== currentUserId) {
@@ -33,7 +32,6 @@ export async function replayOfflineQueue(): Promise<void> {
return
}
- // Set ownership for future ops (both in-memory and persisted)
if (currentUserId) {
setOfflineQueueUserId(currentUserId)
await setQueueUserId(currentUserId)
@@ -55,7 +53,6 @@ export async function replayOfflineQueue(): Promise<void> {
const categoriesStore = useCategoriesStore()
const trnsStore = useTrnsStore()
- // Filter out frontend-ID deletes and group by entity
const filteredOps = []
for (const op of queue) {
if (isLocalId(op.id) && op.type === 'delete') {
diff --git a/app/components/offline/replayHelpers.ts b/app/components/offline/replayHelpers.ts
index 17ca7a58..34b8503a 100644
--- a/app/components/offline/replayHelpers.ts
+++ b/app/components/offline/replayHelpers.ts
@@ -42,9 +42,6 @@ async function validateOpData<T>(
return null
}
-/**
- * Remap local IDs in trn data using the collected remap map.
- */
export function remapTrnIds(data: TrnItem, remapIds: Map<string, string>): TrnItem {
if (data.type === TrnType.Transfer) {
return {
@@ -60,9 +57,6 @@ export function remapTrnIds(data: TrnItem, remapIds: Map<string, string>): TrnIt
}
}
-/**
- * Check if a trn references wallets/categories that don't exist.
- */
export function isTrnOrphaned(
data: TrnItem,
walletsItems: Record<string, unknown>,
@@ -80,9 +74,6 @@ type GroupedOps = {
walletOps: OfflineOp[]
}
-/**
- * Group offline operations by entity type.
- */
export function groupOpsByEntity(ops: OfflineOp[]): GroupedOps {
const walletOps: OfflineOp[] = []
const categoryOps: OfflineOp[] = []
@@ -138,9 +129,6 @@ export function splitCategoryOps(ops: OfflineOp[]): {
return { childOps, parentOps }
}
-/**
- * Extract remap entries (localId -> convexId) from resolved promise results.
- */
export function extractRemaps(results: unknown[]): Array<{ convexId: string, localId: string }> {
const remaps: Array<{ convexId: string, localId: string }> = []
for (const r of results) {
@@ -150,11 +138,6 @@ export function extractRemaps(results: unknown[]): Array<{ convexId: string, loc
return remaps
}
-// --- Per-entity replay functions ---
-
-/**
- * Collect remap entries from resolved promises into the remap map.
- */
export async function collectRemaps(promises: (Promise<unknown> | void | undefined)[], remapIds: Map<string, string>): Promise<void> {
const results = await Promise.all(promises.map(p => p ?? Promise.resolve()))
for (const { convexId, localId } of extractRemaps(results)) {
@@ -167,9 +150,6 @@ type WalletActions = {
saveWallet: (params: { id: string, values: WalletItem }) => Promise<unknown> | void | undefined
}
-/**
- * Replay wallet operations: save or delete each wallet, collecting ID remaps.
- */
export async function replayWalletOps(ops: OfflineOp[], remapIds: Map<string, string>, actions: WalletActions): Promise<void> {
if (ops.length === 0)
return
@@ -193,17 +173,13 @@ type CategoryActions = {
saveCategory: (params: { id: string, isUpdateChildCategoriesColor: boolean, values: CategoryItem }) => Promise<unknown> | void | undefined
}
-/**
- * Replay category operations: parents first, then children (with parentId remapping).
- * Collects ID remaps after each sub-phase.
- */
+/** Parents first, then children (with parentId remapping). */
export async function replayCategoryOps(ops: OfflineOp[], remapIds: Map<string, string>, actions: CategoryActions): Promise<void> {
if (ops.length === 0)
return
const { childOps, parentOps } = splitCategoryOps(ops)
- // Parents first
if (parentOps.length > 0) {
const promises: (Promise<unknown> | void | undefined)[] = []
for (const op of parentOps) {
@@ -223,7 +199,6 @@ export async function replayCategoryOps(ops: OfflineOp[], remapIds: Map<string,
await collectRemaps(promises, remapIds)
}
- // Children second (remap parentId if needed)
if (childOps.length > 0) {
const promises: (Promise<unknown> | void | undefined)[] = []
for (const op of childOps) {
@@ -255,10 +230,7 @@ type TrnContext = {
walletsItems: Record<string, unknown>
}
-/**
- * Replay trn operations: remap wallet/category IDs, skip orphaned trns.
- * Returns the number of orphaned trns that were skipped.
- */
+/** Returns count of orphaned trns that were skipped. */
export async function replayTrnOps(ops: OfflineOp[], remapIds: Map<string, string>, actions: TrnActions, context: TrnContext): Promise<number> {
if (ops.length === 0)
return 0
@@ -299,9 +271,6 @@ type SettingsActions = {
saveLocale: (locale: string) => void
}
-/**
- * Replay user settings operations: validate and apply base currency and locale changes.
- */
export async function replaySettingsOps(ops: OfflineOp[], actions: SettingsActions): Promise<void> {
for (const op of ops) {
const settings = await validateOpData(op, settingsSchema, 'settings')
diff --git a/app/components/stat/Wrap.vue b/app/components/stat/Wrap.vue
index 1779d173..3c3151b7 100644
--- a/app/components/stat/Wrap.vue
+++ b/app/components/stat/Wrap.vue
@@ -50,7 +50,6 @@ const incomeTrnsIds = computed(() => trnsStore.getStoreTrnsIds({
</script>
<template>
- <!-- Split -->
<div
v-if="props.activeTab === 'split'"
class="grid max-w-7xl gap-8 px-2 pb-24 lg:px-4 xl:py-2 2xl:px-8 @3xl/page:grid-cols-2 @3xl/page:gap-8"
@@ -68,7 +67,6 @@ const incomeTrnsIds = computed(() => trnsStore.getStoreTrnsIds({
/>
</div>
- <!-- Net income, income, expense -->
<StatItem
v-else
v-bind="sharedItemProps"
diff --git a/app/components/trnForm/useTrnsFormStore.ts b/app/components/trnForm/useTrnsFormStore.ts
index 397614fc..e04ce1d2 100644
--- a/app/components/trnForm/useTrnsFormStore.ts
+++ b/app/components/trnForm/useTrnsFormStore.ts
@@ -181,7 +181,6 @@ export const useTrnsFormStore = defineStore('trnForm', () => {
}
async function onSubmit() {
- // Validate wallet/category exist before formatting
if (values.trnType !== TrnType.Transfer) {
if (!values.walletId || !walletsStore.items?.[values.walletId]) {
showErrorToast('trnForm.errors.selectWallet')
diff --git a/app/components/trns/useTrnsStore.ts b/app/components/trns/useTrnsStore.ts
index 2c6fa22c..97f694fd 100644
--- a/app/components/trns/useTrnsStore.ts
+++ b/app/components/trns/useTrnsStore.ts
@@ -156,7 +156,6 @@ export const useTrnsStore = defineStore('trns', () => {
async function deltaSync(syncMeta: TrnsSyncMeta, cachedTrns: Trns): Promise<void> {
const { api, client } = useConvexClientWithApi()
- // Fetch delta changes and current hash in parallel
const [changedTrns, hashResult] = await Promise.all([
fetchAllPages<ConvexTrnDoc>(client, api.trns.delta, { since: syncMeta.lastSyncedAt }),
client.query(api.trns.idsHash, {}) as Promise<{ hash: string, serverTime: number } | null>,
@@ -170,14 +169,12 @@ export const useTrnsStore = defineStore('trns', () => {
const { hash: currentHash, serverTime } = hashResult
- // Start with cached data and apply delta
let data: Trns = { ...cachedTrns }
if (changedTrns.length > 0) {
const changedMap = convexTrnsToMap(changedTrns)
data = { ...data, ...changedMap }
}
- // Check if hash matches after applying delta
const localHash = xorIdsHash(Object.keys(data).filter(id => !isLocalId(id)))
if (localHash !== currentHash) {
// Hash mismatch = deletions or missed changes → fallback to fullSync
@@ -243,7 +240,6 @@ export const useTrnsStore = defineStore('trns', () => {
// Frontend IDs are always treated as new creates (server generates real ID)
const isExisting = !isLocalId(id) && items.value && id in items.value
- // Optimistic UI
setTrns({ ...(items.value ?? {}), [id]: valuesWithEditDate })
if (!pushSaveOp({ entity: 'trns', id, isDemo: !!isDemo.value, isExisting: !!isExisting, values }))
@@ -276,7 +272,6 @@ export const useTrnsStore = defineStore('trns', () => {
walletId: asConvexId<'wallets'>(values.walletId),
}
- // Fire-and-forget mutation, cleanup on success
const mutation = isExisting
? client.mutation(api.trns.update, { id: asConvexId<'trns'>(id), ...trnData })
: client.mutation(api.trns.create, trnData)
@@ -301,7 +296,6 @@ export const useTrnsStore = defineStore('trns', () => {
if (!pushDeleteOp({ entity: 'trns', id, isDemo: !!isDemo.value }))
return
- // Fire-and-forget mutation, cleanup on success
const { api, client } = useConvexClientWithApi()
return handleMutationResult({
action: 'delete',
@@ -314,10 +308,7 @@ export const useTrnsStore = defineStore('trns', () => {
})
}
- /**
- * Remove trns from store only (optimistic UI cleanup).
- * Does NOT fire mutations or push to offline queue.
- */
+ /** Remove trns from store only. Does NOT fire mutations or push to offline queue. */
function removeTrnsFromStore(trnsIds: TrnId[]) {
if (!items.value)
return
@@ -332,7 +323,6 @@ export const useTrnsStore = defineStore('trns', () => {
if (!items.value || !walletsStore.items || !categoriesStore.items)
return null
- // Trn
const trn = items.value[id]
if (!trn)
return null
@@ -357,7 +347,6 @@ export const useTrnsStore = defineStore('trns', () => {
return null
}
- // Transfer
if (trn.type === TrnType.Transfer) {
const expenseWallet = walletsStore.items[trn.expenseWalletId]
if (!expenseWallet)
@@ -377,7 +366,6 @@ export const useTrnsStore = defineStore('trns', () => {
}
}
- // Regular transaction
const wallet = walletsStore.items[trn.walletId]
if (!wallet)
return null
diff --git a/app/components/wallets/page/List.vue b/app/components/wallets/page/List.vue
index 6c4a5f28..83fd974d 100644
--- a/app/components/wallets/page/List.vue
+++ b/app/components/wallets/page/List.vue
@@ -66,7 +66,6 @@ function hasGroups(groups: Record<string, unknown> | undefined) {
<template>
<UiPage>
- <!-- Header -->
<UiHeader>
<UiHeaderTitle>{{ t('wallets.name') }}</UiHeaderTitle>
@@ -117,7 +116,6 @@ function hasGroups(groups: Record<string, unknown> | undefined) {
</template>
</UiHeader>
- <!-- Empty -->
<div
v-if="!walletsStore.hasItems"
class="flex-center grow flex-col"
@@ -132,21 +130,17 @@ function hasGroups(groups: Record<string, unknown> | undefined) {
</NuxtLink>
</div>
- <!-- Content -->
<div
v-else
class="grid max-w-5xl grow px-2 lg:px-4 2xl:px-8 @xl/page:grid-cols-2 @xl/page:gap-6 @3xl/page:gap-12"
>
- <!-- Right -->
<div class="grid content-start gap-3 @xl/page:order-1 @xl/page:gap-4 @xl/page:pt-1 @3xl/main:max-w-sm">
- <!-- Wallets Currencies -->
<WalletsCurrencies
v-if="walletsStore.currenciesUsed.length > 1 && groupedBy !== 'currency'"
:currencyFiltered
@selectFilterCurrency="code => currencyFiltered = code"
/>
- <!-- Total -->
<div class="flex flex-wrap justify-stretch gap-2 @2xl/page:justify-start">
<StatSumItem
:title="t('money.types.total')"
@@ -172,7 +166,6 @@ function hasGroups(groups: Record<string, unknown> | undefined) {
/>
</div>
- <!-- Left content -->
<div class="@3xl/main:max-w-sm">
<div class="mb-2 flex min-h-12 items-center gap-2 md:pt-2 ">
<UiTabsScroll>
@@ -218,9 +211,7 @@ function hasGroups(groups: Record<string, unknown> | undefined) {
</div>
</div>
- <!-- Wallets List -->
<div class="md:max-w-lg @xl/page:max-w-lg">
- <!-- No grouping -->
<div
v-if="groupedBy === 'none'"
class="border-item-4 bg-item-2 rounded-xl md:max-w-lg"
@@ -233,7 +224,6 @@ function hasGroups(groups: Record<string, unknown> | undefined) {
/>
</div>
- <!-- Grouping -->
<div
v-if="groupedBy !== 'none' && groupedWalletsWithIds"
class="grid gap-4"
@@ -345,6 +335,5 @@ function hasGroups(groups: Record<string, unknown> | undefined) {
@confirm="confirmDelete"
/>
- <!-- Sort Modal -->
<WalletsSortModal v-if="isSortModalOpen" @close="isSortModalOpen = false" />
</template>
diff --git a/app/components/wallets/useWalletsStore.ts b/app/components/wallets/useWalletsStore.ts
index dcc02b75..baf68f9b 100644
--- a/app/components/wallets/useWalletsStore.ts
+++ b/app/components/wallets/useWalletsStore.ts
@@ -59,7 +59,6 @@ export const useWalletsStore = defineStore('wallets', () => {
// Frontend IDs are always treated as new creates (server generates real ID)
const isExisting = !isLocalId(id) && items.value && id in items.value
- // Set order to max+1 for new wallets
if (!isExisting) {
const maxOrder = Object.values(items.value ?? {}).reduce(
(max, w) => Math.max(max, w.order ?? 0),
@@ -68,7 +67,6 @@ export const useWalletsStore = defineStore('wallets', () => {
values = { ...values, order: maxOrder + 1 }
}
- // Optimistic UI
setWallets({
...(items.value ?? {}),
[id]: values,
@@ -93,7 +91,6 @@ export const useWalletsStore = defineStore('wallets', () => {
type: values.type,
}
- // Fire-and-forget mutation, cleanup on success
const mutation = isExisting
? client.mutation(api.wallets.update, { id: asConvexId<'wallets'>(id), ...walletData })
: client.mutation(api.wallets.create, walletData)
@@ -110,7 +107,6 @@ export const useWalletsStore = defineStore('wallets', () => {
}
function saveWalletsOrder(ids: WalletId[]) {
- // Optimistic update
const updated = { ...(items.value ?? {}) } as Wallets
for (let i = 0; i < ids.length; i++) {
const walletId = ids[i]!
@@ -220,19 +216,16 @@ export const useWalletsStore = defineStore('wallets', () => {
const currenciesUsed = computed<CurrencyCode[]>(() => uniqueElementsBy(itemsComputed.value, 'currency'))
function deleteWallet(id: WalletId, trnsIds?: TrnId[]) {
- // Optimistic UI
const wallets = { ...(items.value ?? {}) }
delete wallets[id]
setWallets(wallets)
- // Optimistic: remove trns from store immediately (backend cascade handles actual deletion)
if (trnsIds?.length)
trnsStore.removeTrnsFromStore(trnsIds)
if (!pushDeleteOp({ entity: 'wallets', id, isDemo: !!isDemo.value }))
return
- // Fire-and-forget mutation, cleanup on success
const { api, client } = useConvexClientWithApi()
return handleMutationResult({
action: 'delete',
diff --git a/app/composables/useStoreSync.ts b/app/composables/useStoreSync.ts
index 988da319..e321887e 100644
--- a/app/composables/useStoreSync.ts
+++ b/app/composables/useStoreSync.ts
@@ -13,11 +13,6 @@ import { createLogger } from '~/utils/logger'
const logger = createLogger('store-sync')
-/**
- * When true, all localforage persist operations are skipped.
- * Set by clearLocalData() to prevent in-flight store inits and mutation callbacks
- * from re-writing data after cleanup. Reset by loadDataFromDB().
- */
let _persistBlocked = false
export function blockPersist(): void {
@@ -73,10 +68,6 @@ export function pushDeleteOp(opts: {
return true
}
-/**
- * Merge pending offline ops on top of server data during store init.
- * Handles updates, deletes, and cleanup of stale frontend IDs.
- */
export async function mergeOfflineOps<T>(
data: Record<string, T>,
entity: EntityType,
@@ -111,10 +102,6 @@ export async function mergeOfflineOps<T>(
export type RemapInfo = { convexId: string, localId: string }
-/**
- * Handle mutation .then/.catch: remove offline op, remap frontend ID, toast errors.
- * Returns a promise that resolves with remap info (for creates) or void.
- */
export function handleMutationResult<T>(opts: {
action: 'create' | 'delete' | 'update'
entity: EntityType
@@ -134,7 +121,6 @@ export function handleMutationResult<T>(opts: {
else
await removeOfflineOps(opts.entity, ids)
- // Remap frontend ID to Convex ID for new items (single create only)
if (opts.action === 'create' && !Array.isArray(opts.id) && result && opts.items) {
const convexId = String(result)
const current = opts.items.value
diff --git a/app/middleware/auth.global.ts b/app/middleware/auth.global.ts
index 8c3f9909..68b051d5 100644
--- a/app/middleware/auth.global.ts
+++ b/app/middleware/auth.global.ts
@@ -5,8 +5,6 @@ import { createLogger } from '~/utils/logger'
const logger = createLogger('auth/middleware')
export default defineNuxtRouteMiddleware(async (to) => {
- // OTT can arrive on any route (callbackURL is not always preserved).
- // Redirect to /auth/callback which handles OTT verification on the client.
if (to.query.ott && to.path !== '/auth/callback') {
return navigateTo({
path: '/auth/callback',
@@ -14,13 +12,11 @@ export default defineNuxtRouteMiddleware(async (to) => {
}, { replace: true })
}
- // Auth callback page handles OTT verification — skip all auth checks
if (to.path === '/auth/callback')
return
const { isDemo } = useDemo()
- // Handle demo mode routing
if (isDemo.value) {
if (to.path === '/login') {
return navigateTo(getSafeRedirectPath(to.query.redirect))
@@ -31,11 +27,6 @@ export default defineNuxtRouteMiddleware(async (to) => {
const authClient = useAuth()
const isLoginPage = to.path === '/login'
- // Has cached auth: let user through immediately, initialize session in background.
- // The getSession() call is needed once to establish the cross-domain session
- // so that useSession() reactive ref updates in the app.
- // Only call once per page load — repeated calls trigger $sessionSignal loop
- // in the cross-domain client (each response sets a cookie → signal → refetch).
if (hasAuthCookie()) {
if (!isSessionInitialized() && navigator.onLine) {
setSessionInitialized(true)
@@ -61,11 +52,9 @@ export default defineNuxtRouteMiddleware(async (to) => {
return
}
- // No cached auth on login page — nothing to verify, let user through.
if (isLoginPage)
return
- // Offline without cached auth — can't verify, redirect to login
if (!navigator.onLine) {
const redirect = to.fullPath === '/' ? undefined : { redirect: to.fullPath }
return navigateTo({
@@ -74,7 +63,6 @@ export default defineNuxtRouteMiddleware(async (to) => {
})
}
- // No cached auth: must verify (blocking)
try {
const session = await authClient.getSession()
const user = session.data?.user || null
diff --git a/app/pages/auth/callback.vue b/app/pages/auth/callback.vue
index fa8d85d6..1cbb244a 100644
--- a/app/pages/auth/callback.vue
+++ b/app/pages/auth/callback.vue
@@ -16,9 +16,6 @@ onMounted(async () => {
return
}
- // Service worker can replay callback navigation after the first run already
- // succeeded. If auth cookie is set, the first callback already completed —
- // skip verify and redirect to the app.
if (hasAuthCookie()) {
const redirectTo = getSafeRedirectPath(localStorage.getItem('finapp.authRedirect'))
localStorage.removeItem('finapp.authRedirect')
@@ -41,12 +38,6 @@ onMounted(async () => {
return
}
- // crossDomainClient's onSuccess hook already processed Set-Better-Auth-Cookie
- // from the OTT verify response and wrote the SIGNED session token to localStorage.
- // Call getSession WITHOUT Authorization header — let the cross-domain client
- // send the signed token via Better-Auth-Cookie. Using Authorization: Bearer
- // with the raw (unsigned) token causes the server to skip cookie injection
- // and the bearer plugin can't verify an unsigned token.
const session = await authClient.getSession()
if (session.data?.user) {
@@ -54,8 +45,6 @@ onMounted(async () => {
setAuthCookie(uid)
- // Set Convex auth BEFORE navigating so that loadDataFromDB()
- // queries are queued behind the token fetch (WebSocket pauses).
const { $ensureConvexAuth } = useNuxtApp()
;($ensureConvexAuth as () => void)()
diff --git a/app/pages/login.vue b/app/pages/login.vue
index 1c29db5a..982bfea7 100644
--- a/app/pages/login.vue
+++ b/app/pages/login.vue
@@ -28,24 +28,15 @@ async function signInWithGoogle() {
isDemo.value = null
isLoading.value = true
- // Remember where user wanted to go, so callback page can redirect back.
- // Using localStorage (synchronous) instead of cookie — cookie may not flush
- // before signIn.social() triggers full-page navigation to Google.
const redirectTo = getSafeRedirectPath(route.query.redirect)
localStorage.setItem('finapp.authRedirect', redirectTo)
- // Clear stale cross-domain cookies before initiating OAuth.
- // After signOut, background responses (getSession, atom refetch) can race
- // with localStorage.removeItem and re-write stale cookies. The stale
- // __Secure-better-auth.state confuses the OAuth flow.
localStorage.removeItem('better-auth_cookie')
localStorage.removeItem('better-auth_session_data')
try {
const result = await signIn.social({ callbackURL: `${window.location.origin}/auth/callback`, provider: 'google' })
- // crossDomainClient returns {url, redirect: true} instead of auto-redirecting.
- // Manually redirect to the Google OAuth URL.
if (result.data?.url) {
window.location.href = result.data.url
}
diff --git a/convex/categories.ts b/convex/categories.ts
index 942ea3f6..cb59f21f 100644
--- a/convex/categories.ts
+++ b/convex/categories.ts
@@ -8,7 +8,6 @@ import { action, internalMutation, internalQuery, mutation, query } from './_gen
import { getAuthUser, getOwnEntity, requireAuthUser, validateStringLength } from './shared'
import { toggleTrnsHash } from './trnsHash'
-// --- Shared helpers ---
async function validateParentId(ctx: MutationCtx, parentId: Id<'categories'> | 0, userId: string, selfId?: Id<'categories'>) {
if (parentId === 0)
@@ -65,8 +64,6 @@ async function updateCategoryCore(
return now
}
-// --- Queries & Mutations ---
-
export const list = query({
args: {},
handler: async (ctx) => {
@@ -200,7 +197,6 @@ export const remove = action({
userId: user._id,
})
- // Paginated trn deletion
let cursor: string | null = null
let isDone = false
while (!isDone) {