screenModelScope is backed by PlatformMainDispatcher (Main.immediate),
so direct interactor calls run DB queries and file I/O on the UI
thread. Switch reactive flows with .flowOn(Dispatchers.IO) and wrap
suspend calls in withContext(Dispatchers.IO).
Per review on PR #8 (#8):
- Split @Upsert into @Insert(OnConflictStrategy.REPLACE) + @Update in all 3 DAOs.
@Upsert returns -1 on the update path, so callers wanting the row ID would
get a junk value. Interactors now call insert vs update based on id == 0.
UpsertCategory returns category.id explicitly for the id != 0 branch.
- Add @Transaction to the 3 @Relation queries (ExpenseDao.subscribeAll,
ExpenseDao.subscribeByDateRange, RecurringExpenseDao.subscribeAll). This
silences the KSP warnings the PR body mentioned and makes the intent
explicit.
- Switch MainApplication seeding from a fire-and-forget CoroutineScope to
runBlocking(Dispatchers.IO). A fast first-tap on HomeScreen could otherwise
call GetCategories.awaitDefault() before seeding completed and crash.
- Add documenting comment on CategoryDao.getDefault() noting that the
'only one isDefault = 1' invariant is maintained at the interactor layer
(partial unique index would be a v2 migration).
- Add trailing newline to app/build.gradle.kts.
- File follow-up issue #9 for flipping exportSchema to true before any v2
migration lands.