Refactor thread responses into an enum.

Lays ground work for different types of views, i.e. email, news, docs, etc.
This commit is contained in:
2024-08-26 21:48:53 -07:00
parent 446fcfe37f
commit 760cec01a8
10 changed files with 190 additions and 161 deletions

View File

@@ -341,25 +341,28 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
})
.collect(),
);
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();
match &data.thread {
graphql::show_thread_query::ShowThreadQueryThread::EmailThread(
ShowThreadQueryThreadOnEmailThread {
thread_id,
subject,
messages,
},
) => {
let mut open_messages: HashSet<_> = messages
.iter()
.filter(|msg| msg.tags.iter().any(|t| t == "unread"))
.map(|msg| msg.id.clone())
.collect();
if open_messages.is_empty() {
open_messages = messages.iter().map(|msg| msg.id.clone()).collect();
}
model.context = Context::ThreadResult {
thread: data.thread,
open_messages,
};
}
}
model.context = Context::ThreadResult {
thread: data.thread,
open_messages,
};
}
Msg::ShowThreadResult(bad) => {
error!("show_thread_query error: {bad:#?}");