mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
keep selection when migrating several accounts (#2011)
postpone selection after the last migration as migrateAccount() currently selects the migrated account. before, the selectAccount() call was useless if another migrateAccount() call follows.
This commit is contained in:
@@ -52,6 +52,8 @@ public class AccountManager {
|
||||
|
||||
public void migrateToDcAccounts(ApplicationContext context) {
|
||||
try {
|
||||
int selectAccountId = 0;
|
||||
|
||||
File[] files = context.getFilesDir().listFiles();
|
||||
for (File file : files) {
|
||||
// old accounts have the pattern "messenger*.db"
|
||||
@@ -61,11 +63,17 @@ public class AccountManager {
|
||||
String selName = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getString("curr_account_db_name", "messenger.db");
|
||||
if (file.getName().equals(selName)) {
|
||||
context.dcAccounts.selectAccount(accountId);
|
||||
// postpone selection as it will otherwise be overwritten by the next migrateAccount() call
|
||||
// (if more than one account needs to be migrated)
|
||||
selectAccountId = accountId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selectAccountId != 0) {
|
||||
context.dcAccounts.selectAccount(selectAccountId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user