To ensure that the "select last row" will work properly after inserting
the task, the code was updated to run inside a transaction. This is
required because it "only works on the connection where the write
happened". Despite working fine in Android, this was not working on iOS.
Source: https://github.com/cashapp/sqldelight/issues/1828
Having the last inserted row in the Task table will allow the app to
schedule an alarm right after inserting the task. The lack of this
support is what is causing the bug where the alarm is not schedule when
using the botom sheet.
In the database we are storing the time in milliseconds, however, the
encoder was wrongly set as "fromEpochSeconds". The function was updated
to use the appropriate API.
Since the SQLDelight does have a callback when the database schema is
created, the solution was checking if the database is created before
inserting the categories. The library creates the database on a specific
folder, which is now checked on iOS variant.
This change also required a few structure changes, such as the place of
the strings and implementing the resource access on each platform.
Using Koin and `expect class`, the code inside `commonMain` is
platform-agnostic. Now, every module implements its own platform driver.
For now, the prepopulation will only be executed in Android platform.
When the time comes, we refactor the code to also make it agnostic.
* Update room to v2.5.0
* 👽️ Update imports on new Room version
New Room version moved the `OnConflictStrategy` to a Companion object,
which means that the import should reflect this change.
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Igor Escodro <escodro@outlook.com>
A new class called `AppCoroutineScope` was created to wrap the
functionality of a `CoroutineScope` without exposing the `.cancel()`
API. Since this scope should match the lifecycle of the App, it should
never be cancelled. This class will avoid human error by not exposing
the function to cancel the scope.
The decision to create a wrapper instead of implementing the
`CoroutineScope` interface was because the `.cancel()` function is not
part of the interface itself, it's an extension function. Due to the
Liskov Substitution Principle, it would be possible to attribute a
`CustomCoroutineScope` in a `CoroutineScope` interface, making it
possible to access the `.cancel()` function even if it was implemented
in the custom one.
For the moment, only the `.launch()` function is exposed. If other
functions (such as `.async()`) is needed, than future changes will add
them.
* Update dependency com.pinterest:ktlint to v0.48.0
* 🚨 Add trailing comma
Finally this rule is in place for Ktlint. Command was executed to add
trailing comma in every single Kotlin file.
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Igor Escodro <escodro@outlook.com>
While creating the new ApplicationScope, I didn't realized that a Scope
was already in place. That was confusing, especially because both have
the same goal. In order to make it better, one was removed and the one
with qualifier is kept.