fix: clean up tag toggling event code

This commit is contained in:
atagen 2025-06-22 21:41:24 +10:00
parent 091ee4d926
commit 6eb2e5fd9c

View File

@ -305,14 +305,14 @@ impl NiriTag {
ChangeTag(t)
}
TagCmd::ToggleTag(t) => {
let visible = *self.tags.entry(t).or_insert(false);
if visible {
let new_state = !*self.tags.entry(t).or_insert(false);
if new_state {
send_event(self.ev_tx.clone(), TagEvent::TagEnabled(t)).await;
} else {
send_event(self.ev_tx.clone(), TagEvent::TagDisabled(t)).await;
}
tracing::debug!("toggling tag {} to {}", t, !visible);
self.tags.insert(t, !visible);
tracing::debug!("toggling tag {} to {}", t, new_state);
self.tags.insert(t, new_state);
ChangeTag(t)
}
},