update ui
This commit is contained in:
@@ -12,9 +12,7 @@ use crate::backend::Backend;
|
||||
pub struct Inbox {
|
||||
state: InboxReadState,
|
||||
/// Set once the stored state has been read for the current user.
|
||||
state_loaded: bool,
|
||||
/// Unread notification groups, published by the inbox panel for the sidebar badge.
|
||||
pub unread_count: usize,
|
||||
loaded: bool,
|
||||
}
|
||||
|
||||
impl Inbox {
|
||||
@@ -25,16 +23,7 @@ impl Inbox {
|
||||
|
||||
/// Whether the stored state has been read for the current user.
|
||||
pub fn is_loaded(&self) -> bool {
|
||||
self.state_loaded
|
||||
}
|
||||
|
||||
/// Publish the unread count derived by the inbox panel.
|
||||
pub fn set_unread_count(&mut self, count: usize, cx: &mut Context<Self>) {
|
||||
if self.unread_count == count {
|
||||
return;
|
||||
}
|
||||
self.unread_count = count;
|
||||
cx.notify();
|
||||
self.loaded
|
||||
}
|
||||
|
||||
/// Mark the events of one notification group read, then bound the id sets.
|
||||
@@ -83,8 +72,7 @@ impl Inbox {
|
||||
/// Load the stored state for current user.
|
||||
pub(crate) fn activate(&mut self, me: PublicKey, client: Client, cx: &mut Context<Self>) {
|
||||
self.state = InboxReadState::default();
|
||||
self.state_loaded = false;
|
||||
self.unread_count = 0;
|
||||
self.loaded = false;
|
||||
cx.notify();
|
||||
|
||||
let backend = Backend::global(cx);
|
||||
@@ -104,7 +92,7 @@ impl Inbox {
|
||||
Err(error) => log::warn!("failed to load inbox state: {error}"),
|
||||
}
|
||||
|
||||
this.state_loaded = true;
|
||||
this.loaded = true;
|
||||
cx.notify();
|
||||
})?;
|
||||
|
||||
@@ -116,8 +104,7 @@ impl Inbox {
|
||||
/// Clear the state of the signed-out user.
|
||||
pub(crate) fn reset(&mut self, cx: &mut Context<Self>) {
|
||||
self.state = InboxReadState::default();
|
||||
self.state_loaded = false;
|
||||
self.unread_count = 0;
|
||||
self.loaded = false;
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user