web: handle expand/collapse of messages separate from unread status
This commit is contained in:
@@ -119,8 +119,8 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
}
|
||||
});
|
||||
}
|
||||
Context::ThreadResult(_) => (), // do nothing (yet?)
|
||||
Context::None => (), // do nothing (yet?)
|
||||
Context::ThreadResult { .. } => (), // do nothing (yet?)
|
||||
Context::None => (), // do nothing (yet?)
|
||||
};
|
||||
}
|
||||
Msg::PreviousPage => {
|
||||
@@ -139,8 +139,8 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
});
|
||||
}
|
||||
|
||||
Context::ThreadResult(_) => (), // do nothing (yet?)
|
||||
Context::None => (), // do nothing (yet?)
|
||||
Context::ThreadResult { .. } => (), // do nothing (yet?)
|
||||
Context::None => (), // do nothing (yet?)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -254,7 +254,25 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
model.context = Context::ThreadResult(data.thread);
|
||||
let mut open_messages: HashSet<_> = data
|
||||
.thread
|
||||
.messages
|
||||
.iter()
|
||||
.filter(|msg| msg.tags.iter().any(|t| t == "unread"))
|
||||
.map(|msg| msg.id.clone())
|
||||
.collect();
|
||||
if open_messages.is_empty() {
|
||||
open_messages = data
|
||||
.thread
|
||||
.messages
|
||||
.iter()
|
||||
.map(|msg| msg.id.clone())
|
||||
.collect();
|
||||
}
|
||||
model.context = Context::ThreadResult {
|
||||
thread: data.thread,
|
||||
open_messages,
|
||||
};
|
||||
}
|
||||
Msg::ShowThreadResult(bad) => {
|
||||
error!("show_thread_query error: {bad:#?}");
|
||||
@@ -307,6 +325,18 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
info!("selected threads {selected_threads:?}");
|
||||
}
|
||||
}
|
||||
Msg::MessageCollapse(id) => {
|
||||
if let Context::ThreadResult { open_messages, .. } = &mut model.context {
|
||||
open_messages.remove(&id);
|
||||
info!("open_messages threads {open_messages:?}");
|
||||
}
|
||||
}
|
||||
Msg::MessageExpand(id) => {
|
||||
if let Context::ThreadResult { open_messages, .. } = &mut model.context {
|
||||
open_messages.insert(id);
|
||||
info!("open_messages threads {open_messages:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// `Model` describes our app state.
|
||||
@@ -340,7 +370,10 @@ pub enum Context {
|
||||
pager: FrontPageQuerySearchPageInfo,
|
||||
selected_threads: HashSet<String>,
|
||||
},
|
||||
ThreadResult(ShowThreadQueryThread),
|
||||
ThreadResult {
|
||||
thread: ShowThreadQueryThread,
|
||||
open_messages: HashSet<String>,
|
||||
},
|
||||
}
|
||||
|
||||
pub struct Tag {
|
||||
@@ -394,4 +427,7 @@ pub enum Msg {
|
||||
SelectionMarkAsUnread,
|
||||
SelectionAddThread(String),
|
||||
SelectionRemoveThread(String),
|
||||
|
||||
MessageCollapse(String),
|
||||
MessageExpand(String),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user