Skip to content

Commit

Permalink
Update login and settings handling: add TextBuffer, optimize login da…
Browse files Browse the repository at this point in the history
…ta set, simplify daemon stop logic
  • Loading branch information
nullchinchilla committed Jul 15, 2024
1 parent 1139938 commit e46840e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions binaries/geph5-client-gui/src/tabs/login.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use egui::{Align, Image, Key, Layout, TextEdit, Widget};
use egui::{Align, Image, Key, Layout, TextBuffer, TextEdit, Widget};
use geph5_broker_protocol::{BrokerClient, Credential};
use poll_promise::Promise;

Expand All @@ -7,8 +7,6 @@ use crate::{
settings::{get_config, PASSWORD, USERNAME},
};



pub struct Login {
username: String,
password: String,
Expand Down Expand Up @@ -38,8 +36,9 @@ impl Login {
match promise.poll() {
std::task::Poll::Ready(ready) => match ready {
Ok(_) => {
USERNAME.set(self.username.clone());
PASSWORD.set(self.password.clone());
self.check_login = None;
USERNAME.set(self.username.take());
PASSWORD.set(self.password.take());
}
Err(err) => {
let err = format!("{:?}", err);
Expand Down
2 changes: 1 addition & 1 deletion binaries/geph5-client-gui/src/tabs/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub static LOCATION_LIST: Lazy<Mutex<RefreshCell<ExitList>>> =

pub fn render_settings(_ctx: &egui::Context, ui: &mut egui::Ui) -> anyhow::Result<()> {
if ui.button(l10n("logout")).clicked() {
smol::future::block_on(DAEMON_HANDLE.control_client().stop())?;
DAEMON_HANDLE.stop()?;
USERNAME.set("".into());
PASSWORD.set("".into());
}
Expand Down

0 comments on commit e46840e

Please sign in to comment.