Skip to content

Commit 5092012

Browse files
committed
Fix rudimentary database upgrade on fresh app installation
Improves speed of the first application launch after installation or clearing data + Fixes rudimentary feature alerts after the first sign in
1 parent f419f43 commit 5092012

File tree

1 file changed

+10
-1
lines changed
  • app/src/main/java/org/thunderdog/challegram/unsorted

1 file changed

+10
-1
lines changed

app/src/main/java/org/thunderdog/challegram/unsorted/Settings.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,12 @@ public void onError (LevelDB levelDB, String message, @Nullable Throwable error)
856856
try {
857857
pmcVersion = Math.max(0, pmc.tryGetInt(KEY_VERSION));
858858
} catch (FileNotFoundException e) {
859-
migratePrefsToPmc();
859+
if (isFreshAppInstallation()) {
860+
pmc.putInt(KEY_VERSION, pmcVersion);
861+
pmcVersion = VERSION;
862+
} else {
863+
migratePrefsToPmc();
864+
}
860865
}
861866
if (pmcVersion > VERSION) {
862867
Log.e("Downgrading database version: %d -> %d", pmcVersion, VERSION);
@@ -2291,6 +2296,10 @@ public boolean needProxyLegacyMigrateCheck () {
22912296
return false;
22922297
}
22932298

2299+
private boolean isFreshAppInstallation () {
2300+
return !TdlibManager.getAccountConfigFile().exists() && pmc.getLong(KEY_APP_INSTALLATION_ID, 0) == 0;
2301+
}
2302+
22942303
private void migratePrefsToPmc () {
22952304
// Main
22962305

0 commit comments

Comments
 (0)