Fix index out of bounds after removing account

This commit is contained in:
Bnyro 2023-07-13 16:58:44 +02:00
parent 7f993ee531
commit b7f8125707
1 changed files with 4 additions and 0 deletions

View File

@ -64,6 +64,10 @@ pub fn update_account(account: Account, index: usize) {
pub fn remove_account(index: usize) { pub fn remove_account(index: usize) {
let mut settings = get_prefs(); let mut settings = get_prefs();
settings.accounts.remove(index); settings.accounts.remove(index);
// if the deleted account has been before the current one, the current index needs to decreased too
if index < settings.current_account_index as usize {
settings.current_account_index = settings.current_account_index - 1;
}
save_prefs(&settings); save_prefs(&settings);
} }