Merge pull request #172 from lavafroth/backup-struct-aot

refactor: create a backup struct ahead of time
This commit is contained in:
Adhiraj S. Chauhan 2024-01-19 20:55:02 +05:30 committed by GitHub
commit 622ea98ce7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -85,7 +85,14 @@ impl Settings {
Command::none()
}
Message::LoadDeviceSettings => {
let backups = list_available_backups(&BACKUP_DIR.join(phone.adb_id.clone()));
let backups = list_available_backups(&BACKUP_DIR.join(&phone.adb_id));
let backup = BackupSettings {
backups: backups.clone(),
selected: backups.first().cloned(),
users: phone.user_list.clone(),
selected_user: phone.user_list.first().copied(),
backup_state: String::new(),
};
match Config::load_configuration_file()
.devices
.iter()
@ -93,26 +100,14 @@ impl Settings {
{
Some(device) => {
self.device = device.clone();
self.device.backup = BackupSettings {
backups: backups.clone(),
selected: backups.first().cloned(),
users: phone.user_list.clone(),
selected_user: phone.user_list.first().copied(),
backup_state: String::new(),
};
self.device.backup = backup;
}
None => {
self.device = DeviceSettings {
device_id: phone.adb_id.clone(),
multi_user_mode: phone.android_sdk > 21,
disable_mode: false,
backup: BackupSettings {
backups: backups.clone(),
selected: backups.first().cloned(),
users: phone.user_list.clone(),
selected_user: phone.user_list.first().copied(),
backup_state: String::new(),
},
backup,
}
}
};