summaryrefslogtreecommitdiffstats
path: root/src/components/chats_list.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/chats_list.rs')
-rw-r--r--src/components/chats_list.rs33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/components/chats_list.rs b/src/components/chats_list.rs
index f958ebe..43ee53e 100644
--- a/src/components/chats_list.rs
+++ b/src/components/chats_list.rs
@@ -4,7 +4,14 @@ use jid::BareJID;
use leptos::prelude::*;
use tracing::debug;
-use crate::{chat::{ArcMacawChat, MacawChat}, client::Client, components::{icon::IconComponent, new_chat::NewChatWidget, overlay::Overlay}, icon::Icon, message::{ArcMacawMessage, MacawMessage}, message_subscriptions::MessageSubscriptions};
+use crate::{
+ chat::{ArcMacawChat, MacawChat},
+ client::Client,
+ components::{icon::IconComponent, new_chat::NewChatWidget, overlay::Overlay},
+ icon::Icon,
+ message::{ArcMacawMessage, MacawMessage},
+ message_subscriptions::MessageSubscriptions,
+};
mod chats_list_item;
@@ -22,11 +29,13 @@ pub fn ChatsList() -> impl IntoView {
Ok(c) => {
let mut chats = IndexMap::new();
for ((chat, chat_user), (message, message_user)) in c {
- chats.insert(chat.correspondent.clone(), (
+ chats.insert(
+ chat.correspondent.clone(),
+ (
ArcMacawChat::got_chat_and_user(chat, chat_user).await,
ArcMacawMessage::got_message_and_user(message, message_user).await,
-
- ));
+ ),
+ );
}
set_chats.set(chats);
}
@@ -51,7 +60,10 @@ pub fn ChatsList() -> impl IntoView {
if let Some((chat, _latest_message)) = chats.shift_remove(&to) {
// TODO: check if new message is actually latest message
debug!("chat existed");
- debug!("new message: {}", new_message.message.get().read().body.body);
+ debug!(
+ "new message: {}",
+ new_message.message.get().read().body.body
+ );
chats.insert_before(0, to, (chat.clone(), new_message));
debug!("done setting");
} else {
@@ -79,15 +91,19 @@ pub fn ChatsList() -> impl IntoView {
// TODO: update icon, tooltip on hover.
<div class="header">
<h2>Chats</h2>
- <div class="new-chat header-icon" class:open=open_new_chat >
- <IconComponent icon=Icon::NewBubble24 on:click=move |_| set_open_new_chat.update(|state| *state = !*state)/>
+ <div class="new-chat header-icon" class:open=open_new_chat>
+ <IconComponent
+ icon=Icon::NewBubble24
+ on:click=move |_| set_open_new_chat.update(|state| *state = !*state)
+ />
{move || {
if *open_new_chat.read() {
view! {
<Overlay set_open=set_open_new_chat>
<NewChatWidget set_open_new_chat />
</Overlay>
- }.into_any()
+ }
+ .into_any()
} else {
view! {}.into_any()
}
@@ -102,4 +118,3 @@ pub fn ChatsList() -> impl IntoView {
</div>
}
}
-