Closed rfc2822 closed 1 year ago
I was thinking about checking the amount of subscriptions in the database when launching the app. It the list is empty, synchronize. This won't be an issue when first launching the app, since the synchronization will just do nothing if there's no data stored. However, if there's data in the calendar, the migration will run, and once they are in the db, it won't be called automatically anymore.
The only issue I see is that the app will fetch all the subscriptions from the database every time the user launches the app.
Maybe enqueue a sync when the DB is created the first time?
I have found this snippet: https://stackoverflow.com/a/57933137
In theory we can create a function to check if the database has been initialized with:
Cursor csr = db.query("sqlite_master",null,"name = ?",new String[]{"room_master_table"},null,null,null);
if (csr.getCount() > 0) {
//db is a room database
} else {
// db is not a room database
}
csr.close();
Edit: doesn't seem to work
Okay, I have tested this:
fun exists(context: Context): Boolean = context.getDatabasePath(DATABASE_NAME).exists()
This returns false
the first time the app is launched, but once data has been fetched, it returns true
, so maybe this is the way.
Or maybe add a callback for the DB onCreate?
Or maybe add a callback for the DB onCreate?
Maybe we can add a listener and just run migrateLegacyCalendars
?
Or add an extra to the worker which says to "just run migration"?
Or maybe add a callback for the DB onCreate?
Maybe we can add a listener and just run
migrateLegacyCalendars
?
That sounds fine. Another extra would add more complexity without gain (except when we need it for some reason I don't know yet).
@ArnyminerZ I have updated ICSx5 to 2.1-beta.2 on my phone, and I noticed that after upgrading, all subscriptions are "gone" until I synchronize. (Because only synchronization migrates the calendar subscripttions to DB subscriptions.)
For me, it's not a problem because I know that I only have to refresh, but there are many people who don't know that. The migration should run automatically. What is your suggestion?