added message and event for deleting a server from the list

This commit is contained in:
Martin 2022-01-25 19:48:19 +02:00
parent 54d5a06a0d
commit a86ed49293
2 changed files with 17 additions and 0 deletions

View File

@ -353,6 +353,14 @@ impl PlayState for MainMenuState {
.client()
.map(|init| init.auth_trust(auth_server, trust));
},
MainMenuEvent::DeleteServer { server_index } => {
let net_settings = &mut global_state.settings.networking;
net_settings.servers.remove(server_index);
global_state
.settings
.save_to_file_warn(&global_state.config_dir);
},
}
}

View File

@ -87,6 +87,9 @@ pub enum Event {
// Note: Keeping in case we re-add the disclaimer
//DisclaimerAccepted,
AuthServerTrust(String, bool),
DeleteServer {
server_index: usize,
},
}
pub struct LoginInfo {
@ -164,6 +167,7 @@ enum Message {
TrustPromptAdd,
TrustPromptCancel,
CloseError,
DeleteServer,
/* Note: Keeping in case we re-add the disclaimer
*AcceptDisclaimer, */
}
@ -423,6 +427,11 @@ impl Controls {
*error = None;
}
},
Message::DeleteServer => {
events.push(Event::DeleteServer {
server_index: self.selected_server_index.unwrap(),
});
},
/* Note: Keeping in case we re-add the disclaimer */
/*Message::AcceptDisclaimer => {
if let Screen::Disclaimer { .. } = &self.screen {