diff options
author | 2025-03-24 13:25:23 +0000 | |
---|---|---|
committer | 2025-03-24 13:25:23 +0000 | |
commit | a88a7b0445a20ca57870e4c8a068d9b29ea6e779 (patch) | |
tree | ec6e962ae5483d02d9d6ef30900dc2d48bc745e2 | |
parent | 6814c50b7d36b75b71b9f8a76107f9164afaa7fe (diff) | |
download | macaw-a88a7b0445a20ca57870e4c8a068d9b29ea6e779.tar.gz macaw-a88a7b0445a20ca57870e4c8a068d9b29ea6e779.tar.bz2 macaw-a88a7b0445a20ca57870e4c8a068d9b29ea6e779.zip |
feat: delayed message and presence reception
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | src/main.rs | 23 |
2 files changed, 16 insertions, 8 deletions
@@ -4171,6 +4171,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" name = "stanza" version = "0.1.0" dependencies = [ + "chrono", "jid", "peanuts", "thiserror 2.0.11", diff --git a/src/main.rs b/src/main.rs index 7cc2add..37551c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ use std::path::PathBuf; use std::str::FromStr; use std::sync::Arc; -use chrono::Local; +use chrono::{Local, Utc}; use iced::alignment::Horizontal::Right; use iced::futures::{SinkExt, Stream, StreamExt}; use iced::keyboard::{on_key_press, on_key_release, Key, Modifiers}; @@ -28,7 +28,7 @@ use keyring::Entry; use login_modal::{Creds, LoginModal}; use luz::chat::{Chat, Message as ChatMessage}; use luz::error::CommandError; -use luz::presence::{Offline, Presence}; +use luz::presence::{Offline, Presence, PresenceType}; use luz::CommandMessage; use luz::{roster::Contact, user::User, LuzHandle, UpdateMessage}; use message_view::MessageView; @@ -325,7 +325,10 @@ async fn main() -> iced::Result { // TODO: jid, // TODO: store cached status - status: Presence::Offline(Offline::default()), + status: Presence { + timestamp: Utc::now(), + presence: PresenceType::Offline(Offline::default()), + }, connection_state: ConnectionState::Offline, }), cfg, @@ -440,7 +443,10 @@ impl Macaw { } UpdateMessage::Online(online, vec) => match &mut self.client { Account::LoggedIn(client) => { - client.status = Presence::Online(online); + client.status = Presence { + timestamp: Utc::now(), + presence: PresenceType::Online(online), + }; client.connection_state = ConnectionState::Online; let mut roster = HashMap::new(); for contact in vec { @@ -455,7 +461,10 @@ impl Macaw { // TODO: update all contacts' presences to unknown (offline) match &mut self.client { Account::LoggedIn(client) => { - client.status = Presence::Offline(offline); + client.status = Presence { + timestamp: Utc::now(), + presence: PresenceType::Offline(offline), + }; client.connection_state = ConnectionState::Offline; Task::none() } @@ -649,9 +658,7 @@ impl Macaw { Client { client: handle, jid, - status: Presence::Offline( - Offline::default(), - ), + status: Presence { timestamp: Utc::now(), presence: PresenceType::Offline(Offline::default()) }, connection_state: ConnectionState::Offline, }, ))); |