Mark all messages as seen
This commit is contained in:
parent
43247e2a5c
commit
573f231466
4 changed files with 35 additions and 2 deletions
|
|
@ -124,6 +124,8 @@ impl MsgStore<LogMsg> for Logger {
|
|||
}
|
||||
|
||||
async fn set_seen(&self, _id: &usize, _seen: bool) {}
|
||||
|
||||
async fn set_all_seen(&self, _seen: bool) {}
|
||||
}
|
||||
|
||||
impl Log for Logger {
|
||||
|
|
|
|||
|
|
@ -130,4 +130,5 @@ pub trait MsgStore<M: Msg> {
|
|||
async fn older_msg_id(&self, id: &M::Id) -> Option<M::Id>;
|
||||
async fn newer_msg_id(&self, id: &M::Id) -> Option<M::Id>;
|
||||
async fn set_seen(&self, id: &M::Id, seen: bool);
|
||||
async fn set_all_seen(&self, seen: bool);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
|||
pub fn list_action_key_bindings(&self, bindings: &mut KeyBindingsList) {
|
||||
bindings.binding("s", "toggle current message's seen status");
|
||||
bindings.binding("S", "mark all visible messages as seen");
|
||||
// bindings.binding("ctrl+S", "mark all messages as seen");
|
||||
bindings.binding("ctrl+S", "mark all messages as seen");
|
||||
}
|
||||
|
||||
async fn handle_action_key_event(&mut self, event: KeyEvent, id: Option<&M::Id>) -> bool {
|
||||
|
|
@ -116,6 +116,11 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
key!(Ctrl + 'S') => {
|
||||
// Ctrl + Shift + s, extra hard to hit accidentally
|
||||
self.store.set_all_seen(true).await;
|
||||
return true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
false
|
||||
|
|
|
|||
|
|
@ -267,6 +267,14 @@ impl MsgStore<SmallMessage> for EuphVault {
|
|||
};
|
||||
let _ = self.vault.tx.send(request.into());
|
||||
}
|
||||
|
||||
async fn set_all_seen(&self, seen: bool) {
|
||||
let request = EuphRequest::SetAllSeen {
|
||||
room: self.room.clone(),
|
||||
seen,
|
||||
};
|
||||
let _ = self.vault.tx.send(request.into());
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) enum EuphRequest {
|
||||
|
|
@ -364,6 +372,10 @@ pub(super) enum EuphRequest {
|
|||
id: Snowflake,
|
||||
seen: bool,
|
||||
},
|
||||
SetAllSeen {
|
||||
room: String,
|
||||
seen: bool,
|
||||
},
|
||||
}
|
||||
|
||||
impl EuphRequest {
|
||||
|
|
@ -414,6 +426,7 @@ impl EuphRequest {
|
|||
Self::get_newer_msg_id(conn, room, id, result)
|
||||
}
|
||||
EuphRequest::SetSeen { room, id, seen } => Self::set_seen(conn, room, id, seen),
|
||||
EuphRequest::SetAllSeen { room, seen } => Self::set_all_seen(conn, room, seen),
|
||||
};
|
||||
if let Err(e) = result {
|
||||
// If an error occurs here, the rest of the UI will likely panic and
|
||||
|
|
@ -1004,7 +1017,19 @@ impl EuphRequest {
|
|||
WHERE room = :room
|
||||
AND id = :id
|
||||
",
|
||||
named_params! {":room": room, ":id": id, ":seen": seen},
|
||||
named_params! { ":room": room, ":id": id, ":seen": seen },
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_all_seen(conn: &Connection, room: String, seen: bool) -> rusqlite::Result<()> {
|
||||
conn.execute(
|
||||
"
|
||||
UPDATE euph_msgs
|
||||
SET seen = :seen
|
||||
WHERE room = :room
|
||||
",
|
||||
named_params! { ":room": room, ":seen": seen },
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue