feat: don't save log in memory; log level dropdown can only be interacted with when service is not running

This commit is contained in:
Gabriele Musco 2023-10-11 23:45:15 +02:00
parent ff3e408cf4
commit afaed79a2f
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE
2 changed files with 18 additions and 9 deletions

View file

@ -191,6 +191,9 @@ impl App {
true,
Some(self.get_selected_profile()),
));
self.debug_view
.sender()
.emit(DebugViewMsg::XRServiceActiveChanged(true));
self.set_inhibit_session(true);
} else {
alert(
@ -231,6 +234,9 @@ impl App {
self.main_view
.sender()
.emit(MainViewMsg::XRServiceActiveChanged(false, None));
self.debug_view
.sender()
.emit(DebugViewMsg::XRServiceActiveChanged(false));
self.xr_devices = vec![];
}
@ -312,6 +318,9 @@ impl SimpleComponent for App {
self.main_view
.sender()
.emit(MainViewMsg::XRServiceActiveChanged(false, None));
self.debug_view
.sender()
.emit(DebugViewMsg::XRServiceActiveChanged(false));
if let Some(worker) = self.xrservice_worker.as_ref() {
if let Some(code) = worker.exit_code() {
if code != 0 && code != 15 {

View file

@ -18,12 +18,12 @@ pub enum DebugViewMsg {
ClearLog,
FilterLog(SearchDirection),
LogLevelChanged(LogLevel),
XRServiceActiveChanged(bool),
}
#[tracker::track]
pub struct DebugView {
#[tracker::do_not_track]
log: Vec<String>,
xrservice_active: bool,
#[tracker::do_not_track]
textbuf: sourceview5::Buffer,
#[tracker::do_not_track]
@ -133,12 +133,14 @@ impl SimpleComponent for DebugView {
self.reset();
match message {
Self::Input::XRServiceActiveChanged(active) => {
self.set_xrservice_active(active);
if let Some(dropdown) = self.dropdown.as_ref() {
dropdown.set_sensitive(!active);
}
}
Self::Input::LogLevelChanged(lvl) => {
self.log_level = lvl;
let log = self.log.clone();
self.log = vec![];
self.textbuf.set_text("");
sender.input(Self::Input::LogUpdated(log));
}
Self::Input::FilterLog(direction) => {
let searchbar = self.searchbar.as_ref().unwrap().clone();
@ -180,7 +182,6 @@ impl SimpleComponent for DebugView {
}
}
Self::Input::LogUpdated(n_log) => {
self.log.extend(n_log.clone());
for row in n_log {
let txt = match MonadoLog::new_from_str(row.as_str()) {
Some(o) => match o.level >= self.log_level {
@ -210,7 +211,6 @@ impl SimpleComponent for DebugView {
}
}
Self::Input::ClearLog => {
self.log = vec![];
self.textbuf.set_text("");
}
}
@ -264,8 +264,8 @@ impl SimpleComponent for DebugView {
}
let mut model = Self {
xrservice_active: false,
tracker: 0,
log: vec![],
textbuf,
textview: None,
searchbar: None,