You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR Review: Replace manual dependency injections with Koin
59 files, +882/-860, 9 commits
Summary
Solid migration from manual DI (container classes + AppViewModelProvider) to Koin 4.2.1. The refactor is thorough — all view models, workers, repos, daos, and databases are now managed by Koin modules. A bonus ImportLog extraction improves separation of concerns.
Positive Findings
Clean DI module structure — CoreModule provides the core database layer; AppModule includes it and adds app-specific bindings. The module separation matches the project's core/app structure well.
Structured log events (ImportLog.kt:14-28) — The ImportLogEvent sealed interface (Plural/SimpleString/Raw) replaces raw Resources.getString() calls in the ViewModel. This is a nice design improvement — the ViewModel no longer depends on Resources/AssetManager.
SupervisorJob fix (ArcaeaOfflineApplication.kt:52) — Adding SupervisorJob() to the application scope prevents one failed child from cancelling siblings. Good catch.
Database schema version via MetaDao — The new MetaDao with @RawQuery("PRAGMA user_version") replaces the ad-hoc usePrepared("PRAGMA user_version;") in the old factory. Cleaner abstraction.
Concerns
Medium: getDatabase() no longer caches instances
In all 3 databases (AppDatabase, OcrQueueDatabase, ArcaeaOfflineDatabase), the @Volatile private var instance + synchronized double-checked locking was removed. Now getDatabase() creates a new instance on every call. This relies entirely on Koin's single scope:
This is fine in production since Koin's single calls getDatabase() once. However, any code outside Koin scope that calls getDatabase() will now create duplicate instances. Consider keeping the singleton guard internally and using Koin's single for belt-and-suspenders safety.
Medium: getDatabaseBuilder was made public
Previously private fun getDatabaseBuilder(), now fun (implicitly public). This was necessary for Koin's factory functions. It leaks an internal implementation detail — consider making it internal at minimum.
Low: ArcaeaPackageHelper now constructed inside sendTask
In importArcaeaApkFromInstalled, the helper was previously a lazy property; now it's constructed each time the task runs. This is fine in practice but is a behavioral change.
Verdict
LGTM. The DI migration is clean and consistent across all layers. The ImportLog extraction is thoughtful. No blocking issues — the database singleton observation is worth a follow-up but not a blocker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also refactored some of the design flaws