From 5c54512569fdb0247ae4e0a1f6a10d76dd7e5854 Mon Sep 17 00:00:00 2001 From: alanpoon Date: Thu, 26 Sep 2024 19:32:25 +0800 Subject: [PATCH 01/30] read_receipt_display --- src/home/mod.rs | 2 + src/home/room_read_receipt.rs | 132 ++++++++++++++++++++++++++++++++++ src/home/room_screen.rs | 32 +++++++-- src/shared/avatar.rs | 6 ++ 4 files changed, 167 insertions(+), 5 deletions(-) create mode 100644 src/home/room_read_receipt.rs diff --git a/src/home/mod.rs b/src/home/mod.rs index f4e0a250..4a2df7c0 100644 --- a/src/home/mod.rs +++ b/src/home/mod.rs @@ -4,6 +4,7 @@ pub mod home_screen; pub mod main_content; pub mod room_preview; pub mod room_screen; +pub mod room_read_receipt; pub mod rooms_list; pub mod rooms_sidebar; pub mod spaces_dock; @@ -14,6 +15,7 @@ pub fn live_design(cx: &mut Cx) { rooms_list::live_design(cx); room_preview::live_design(cx); room_screen::live_design(cx); + room_read_receipt::live_design(cx); rooms_sidebar::live_design(cx); main_content::live_design(cx); spaces_dock::live_design(cx); diff --git a/src/home/room_read_receipt.rs b/src/home/room_read_receipt.rs new file mode 100644 index 00000000..4d2c15fe --- /dev/null +++ b/src/home/room_read_receipt.rs @@ -0,0 +1,132 @@ +use makepad_widgets::*; +use matrix_sdk::ruma::{OwnedRoomId, OwnedUserId}; +use crate::shared::avatar::{Avatar}; +live_design!{ + import makepad_draw::shader::std::*; + import crate::shared::avatar::*; + + Sequencer = {{Sequencer}} { + button: { + width: 15.0, + height: 15.0, + text_view = { text = { draw_text: { + text_style: { font_size: 6.0 } + }}} + } + margin: {top: 3, right: 10, bottom: 3, left: 10} + width: Fit, + height: Fit + } +} + +#[derive(Clone, Debug, Default, Eq, Hash, Copy, PartialEq, FromLiveId)] +pub struct AvatarId(pub LiveId); + +#[derive(Live, Widget)] +pub struct Sequencer { + #[redraw] #[live] draw_text: DrawText, + #[rust] area: Area, + #[walk] walk: Walk, + #[live] button: Option, + #[live(false)] hover_actions_enabled: bool, + #[rust] buttons: ComponentMap, + #[rust] read_receipts: Vec +} + +impl LiveHook for Sequencer { +fn after_apply(&mut self, cx: &mut Cx, apply: &mut Apply, index: usize, nodes: &[LiveNode]) { + for button in self.buttons.values_mut() { + if let Some(index) = nodes.child_by_name(index, live_id!(button).as_field()) { + button.apply(cx, apply, index, nodes); + } + } + self.area.redraw(cx); + } +} + +#[derive(Clone, Debug, DefaultNone)] +pub enum SequencerAction { + HoverIn(Rect), + HoverOut, + None +} +impl Widget for Sequencer { + + fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) { + let uid = self.widget_uid(); + for button in self.buttons.values_mut() { + match button.hit(cx, event, self.area){ + Hit::FingerHoverIn(_) => { + let rect = self.area.rect(cx); + cx.widget_action(uid, &scope.path, SequencerAction::HoverIn(rect)); + } + Hit::FingerHoverOut(_) => { + cx.widget_action(uid, &scope.path, SequencerAction::HoverOut); + } + _=>{} + } + } + + } + + fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep { + cx.begin_turtle(walk, Layout::default()); + let button = self.button; + for (i,name) in self.read_receipts.iter().enumerate(){ + if i>4{ + break + } + let btn_id = LiveId(i as u64).into(); + let btn = self.buttons.get_or_insert(cx, btn_id, | cx | { + Avatar::new_from_ptr(cx, button) + }); + btn.set_text(name); + btn.draw(cx, scope); + } + + cx.end_turtle_with_area(&mut self.area); + self.buttons.retain_visible(); + DrawStep::done() + } + + fn widget_to_data(&self, cx: &mut Cx, actions: &Actions, nodes: &mut LiveNodeVec, path: &[LiveId]) -> bool { + false + } + + fn data_to_widget(&mut self, cx: &mut Cx, nodes:&[LiveNode], path: &[LiveId]){ + } +} + +impl SequencerRef { + pub fn get_read_receipts(&self)->Vec{ + if let Some(inner) = self.borrow() { + return inner.read_receipts.clone(); + } + return vec![]; + } + pub fn set_read_receipts(&mut self,cx:&mut Cx , room_id: OwnedRoomId, read_user_id:Vec){ + if let Some(mut inner) = self.borrow_mut() { + inner.read_receipts = read_user_id.iter().map(|f|f.to_string().chars().nth(1).unwrap().to_string()).collect(); + } + } + pub fn hover_in(&self, actions:&Actions)->Option{ + if let Some(item) = actions.find_widget_action(self.widget_uid()) { + match item.cast(){ + SequencerAction::HoverIn(rect) => Some(rect), + _=> None + } + } else { + None + } + } + pub fn hover_out(&self, actions:&Actions)->bool{ + if let Some(item) = actions.find_widget_action(self.widget_uid()) { + match item.cast(){ + SequencerAction::HoverOut => true, + _=> false + } + } else { + false + } + } +} diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index 43aee6cc..518382dc 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -31,6 +31,7 @@ use crate::{ }, sliding_sync::{get_client, submit_async_request, take_timeline_update_receiver, MatrixRequest}, utils::{self, unix_time_millis_to_datetime, MediaFormatConst}, + home::room_read_receipt::* }; use rangemap::RangeSet; @@ -45,6 +46,7 @@ live_design! { import crate::shared::avatar::Avatar; import crate::shared::text_or_image::TextOrImage; import crate::shared::html_or_plaintext::*; + import crate::home::room_read_receipt::*; import crate::profile::user_profile::UserProfileSlidingPane; IMG_DEFAULT_AVATAR = dep("crate://self/resources/img/default_avatar.png") @@ -78,7 +80,6 @@ live_design! { COLOR_OVERLAY_BG = #x000000d8 COLOR_READ_MARKER = #xeb2733 COLOR_PROFILE_CIRCLE = #xfff8ee - FillerY = {width: Fill} FillerX = {height: Fill} @@ -418,7 +419,7 @@ live_design! { message_annotations = {} } - + sequencer = {width: 40, height: 30, margin: {top: (12.0)},hover_actions_enabled:true} message_menu = {} // leave space for reply button (simulate a min width). // once the message menu is done with overlays this wont be necessary. @@ -671,7 +672,7 @@ live_design! { } } } - + tooltip = {} } IMG_SMILEY_FACE_BW = dep("crate://self/resources/img/smiley_face_bw.png") @@ -1077,6 +1078,20 @@ impl Widget for RoomScreen { } if let Event::Actions(actions) = event { + let portal_list = self.portal_list(id!(list)); + let mut tooltip = self.tooltip(id!(tooltip)); + for (_,wr) in portal_list.items_with_actions(actions).iter(){ + let seq = wr.sequencer(id!(sequencer)); + let num_seen = seq.get_read_receipts().len(); + if let Some(rect) = seq.hover_in(actions){ + tooltip.show_with_options(cx, rect.pos, &format!("{} seen",num_seen)); + } + if seq.hover_out(&actions) { + tooltip.hide(cx); + } + } + + for action in actions { // Handle actions on a message, e.g., clicking the reply button or clicking the reply preview. match action.as_widget_action().cast() { @@ -1965,7 +1980,9 @@ fn populate_message_view( media_cache: &mut MediaCache, item_drawn_status: ItemDrawnStatus, ) -> (WidgetRef, ItemDrawnStatus) { - + let receipts = event_tl_item.read_receipts(); + //#123 + let mut new_drawn_status = item_drawn_status; let ts_millis = event_tl_item.timestamp(); @@ -1993,6 +2010,12 @@ fn populate_message_view( live_id!(Message) }; let (item, existed) = list.item_with_existed(cx, item_id, template).unwrap(); + let mut read_receipts =vec![]; + for (ower_user_id,_) in receipts.iter(){ + read_receipts.push(ower_user_id.clone()); + } + item.sequencer(id!(sequencer)).set_read_receipts(cx,room_id.to_owned(),read_receipts); + if existed && item_drawn_status.content_drawn { (item, true) } else { @@ -2458,7 +2481,6 @@ impl SmallStateEventContent for RoomMembershipChange { ItemDrawnStatus::new(), ); }; - item.label(id!(content)).set_text(&preview.format_with(username)); new_drawn_status.content_drawn = true; (item, new_drawn_status) diff --git a/src/shared/avatar.rs b/src/shared/avatar.rs index d4f5b5a9..7bb86140 100644 --- a/src/shared/avatar.rs +++ b/src/shared/avatar.rs @@ -209,6 +209,12 @@ impl Avatar { AvatarDisplayStatus::Text } } + pub fn hit(&mut self, cx: &mut Cx, event: &Event, sweep_area: Area) -> Hit { + event.hits_with_options( + cx, + self.area(), + HitOptions::new().with_sweep_area(sweep_area)) + } } impl AvatarRef { From 4ad555a3d3a4679d05109d056e6f1030d4a0bfc5 Mon Sep 17 00:00:00 2001 From: alanpoon Date: Thu, 3 Oct 2024 16:04:08 +0800 Subject: [PATCH 02/30] merge main --- Cargo.lock | 181 +++---- Cargo.toml | 6 +- src/home/room_preview.rs | 6 +- src/home/room_screen.rs | 882 ++++++++++++++++++-------------- src/home/rooms_list.rs | 119 +++-- src/persistent_state.rs | 11 +- src/profile/user_profile.rs | 1 + src/shared/html_or_plaintext.rs | 2 +- src/shared/mod.rs | 4 +- src/shared/styles.rs | 1 + src/shared/typing_animation.rs | 162 ++++++ src/sliding_sync.rs | 720 +++++++++++++++----------- src/utils.rs | 4 +- 13 files changed, 1261 insertions(+), 838 deletions(-) create mode 100644 src/shared/typing_animation.rs diff --git a/Cargo.lock b/Cargo.lock index 02d3a429..7459b559 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,12 +77,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "allocator-api2" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" - [[package]] name = "android-tzdata" version = "0.1.1" @@ -732,11 +726,10 @@ checksum = "0c03c416ed1a30fbb027ef484ba6ab6f80e1eada675e1a2b92fd673c045a1f1d" [[package]] name = "deadpool" -version = "0.10.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb84100978c1c7b37f09ed3ce3e5f843af02c2a2c431bae5b19230dad2c1b490" +checksum = "6541a3916932fe57768d4be0b1ffb5ec7cbf74ca8c903fdfd5c0fe8aa958f0ed" dependencies = [ - "async-trait", "deadpool-runtime", "num_cpus", "tokio", @@ -753,9 +746,9 @@ dependencies = [ [[package]] name = "deadpool-sqlite" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8010e36e12f3be22543a5e478b4af20aeead9a700dd69581a5e050a070fc22c" +checksum = "2f9cc6210316f8b7ced394e2a5d2833ce7097fb28afb5881299c61bc18e8e0e9" dependencies = [ "deadpool", "deadpool-sync", @@ -790,22 +783,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", - "der_derive", - "flagset", "zeroize", ] -[[package]] -name = "der_derive" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe87ce4529967e0ba1dcf8450bab64d97dfd5010a6256187ffe2e43e6f0e049" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.75", -] - [[package]] name = "deranged" version = "0.3.9" @@ -999,12 +979,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a481586acf778f1b1455424c343f71124b048ffa5f4fc3f8f6ae9dc432dcb3c7" -[[package]] -name = "flagset" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a7e408202050813e6f1d9addadcaafef3dca7530c7ddfb005d4081cce6779" - [[package]] name = "flate2" version = "1.0.28" @@ -1194,19 +1168,18 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", - "allocator-api2", ] [[package]] name = "hashlink" -version = "0.8.4" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" dependencies = [ "hashbrown", ] @@ -1219,9 +1192,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hilog-sys" @@ -1249,9 +1222,9 @@ dependencies = [ [[package]] name = "html5ever" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c13771afe0e6e846f1e67d038d4cb29998a6779f93c809212e4e9c32efd244d4" +checksum = "0ff6858c1f7e2a470c5403091866fa95b36fe0dbac5d771f932c15e5ff1ee501" dependencies = [ "log", "mac", @@ -1457,9 +1430,9 @@ dependencies = [ [[package]] name = "indexed_db_futures" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cc2083760572ee02385ab8b7c02c20925d2dd1f97a1a25a8737a238608f1152" +checksum = "43315957678a70eb21fb0d2384fe86dde0d6c859a01e24ce127eb65a0143d28c" dependencies = [ "accessory", "cfg-if", @@ -1500,9 +1473,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", ] [[package]] @@ -1648,9 +1618,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" +checksum = "0c10584274047cb335c23d3e61bcef8e323adae7c5c8c760540f73610177fc3f" dependencies = [ "cc", "pkg-config", @@ -2025,9 +1995,9 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" [[package]] name = "markup5ever" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16ce3abbeba692c8b8441d036ef91aea6df8da2c6b6e21c7e14d3c18e526be45" +checksum = "d581ff8be69d08a2efa23a959d81aa22b739073f749f067348bd4f4ba4b69195" dependencies = [ "log", "phf", @@ -2063,7 +2033,7 @@ dependencies = [ [[package]] name = "matrix-sdk" version = "0.7.1" -source = "git+https://github.com/project-robius/matrix-rust-sdk?branch=re-export-reactions-type#0788b7a5d075ad2521335b625f7fc50b8308c6db" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#dc055c632c106c6392eeea8efd24c3bb7d756fee" dependencies = [ "anymap2", "aquamarine", @@ -2110,7 +2080,7 @@ dependencies = [ [[package]] name = "matrix-sdk-base" version = "0.7.0" -source = "git+https://github.com/project-robius/matrix-rust-sdk?branch=re-export-reactions-type#0788b7a5d075ad2521335b625f7fc50b8308c6db" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#dc055c632c106c6392eeea8efd24c3bb7d756fee" dependencies = [ "as_variant", "async-trait", @@ -2134,13 +2104,12 @@ dependencies = [ [[package]] name = "matrix-sdk-common" version = "0.7.0" -source = "git+https://github.com/project-robius/matrix-rust-sdk?branch=re-export-reactions-type#0788b7a5d075ad2521335b625f7fc50b8308c6db" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#dc055c632c106c6392eeea8efd24c3bb7d756fee" dependencies = [ "async-trait", "futures-core", "futures-util", "gloo-timers", - "instant", "ruma", "serde", "serde_json", @@ -2156,7 +2125,7 @@ dependencies = [ [[package]] name = "matrix-sdk-crypto" version = "0.7.2" -source = "git+https://github.com/project-robius/matrix-rust-sdk?branch=re-export-reactions-type#0788b7a5d075ad2521335b625f7fc50b8308c6db" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#dc055c632c106c6392eeea8efd24c3bb7d756fee" dependencies = [ "aes", "as_variant", @@ -2196,7 +2165,7 @@ dependencies = [ [[package]] name = "matrix-sdk-indexeddb" version = "0.7.0" -source = "git+https://github.com/project-robius/matrix-rust-sdk?branch=re-export-reactions-type#0788b7a5d075ad2521335b625f7fc50b8308c6db" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#dc055c632c106c6392eeea8efd24c3bb7d756fee" dependencies = [ "anyhow", "async-trait", @@ -2224,7 +2193,7 @@ dependencies = [ [[package]] name = "matrix-sdk-sqlite" version = "0.7.1" -source = "git+https://github.com/project-robius/matrix-rust-sdk?branch=re-export-reactions-type#0788b7a5d075ad2521335b625f7fc50b8308c6db" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#dc055c632c106c6392eeea8efd24c3bb7d756fee" dependencies = [ "async-trait", "deadpool-sqlite", @@ -2246,7 +2215,7 @@ dependencies = [ [[package]] name = "matrix-sdk-store-encryption" version = "0.7.0" -source = "git+https://github.com/project-robius/matrix-rust-sdk?branch=re-export-reactions-type#0788b7a5d075ad2521335b625f7fc50b8308c6db" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#dc055c632c106c6392eeea8efd24c3bb7d756fee" dependencies = [ "base64", "blake3", @@ -2265,13 +2234,12 @@ dependencies = [ [[package]] name = "matrix-sdk-ui" version = "0.7.0" -source = "git+https://github.com/project-robius/matrix-rust-sdk?branch=re-export-reactions-type#0788b7a5d075ad2521335b625f7fc50b8308c6db" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#dc055c632c106c6392eeea8efd24c3bb7d756fee" dependencies = [ "as_variant", "async-once-cell", "async-rx", "async-stream", - "async-trait", "async_cell", "chrono", "eyeball", @@ -2294,6 +2262,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", + "tokio-stream", "tracing", "unicode-normalization", ] @@ -2328,13 +2297,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.9" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ + "hermit-abi", "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2648,17 +2618,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkcs7" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d79178be066405e0602bf3035946edef6b11b3f9dde46dfe5f8bfd7dea4b77e7" -dependencies = [ - "der", - "spki", - "x509-cert", -] - [[package]] name = "pkcs8" version = "0.10.2" @@ -2784,9 +2743,9 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4e75767fbc9d92b90e4d0c011f61358cde9513b31ef07ea3631b15ffc3b4fd" +checksum = "666f0f59e259aea2d72e6012290c09877a780935cc3c18b1ceded41f3890d59c" dependencies = [ "bitflags 2.4.1", "memchr", @@ -3144,7 +3103,7 @@ checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" [[package]] name = "ruma" version = "0.10.1" -source = "git+https://github.com/matrix-org/ruma?rev=f25b3220d0c3ece7720020ed180af4955a855402#f25b3220d0c3ece7720020ed180af4955a855402" +source = "git+https://github.com/ruma/ruma?rev=1ae98db9c44f46a590f4c76baf5cef70ebb6970d#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" dependencies = [ "assign", "js_int", @@ -3160,7 +3119,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.18.0" -source = "git+https://github.com/matrix-org/ruma?rev=f25b3220d0c3ece7720020ed180af4955a855402#f25b3220d0c3ece7720020ed180af4955a855402" +source = "git+https://github.com/ruma/ruma?rev=1ae98db9c44f46a590f4c76baf5cef70ebb6970d#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" dependencies = [ "as_variant", "assign", @@ -3183,7 +3142,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.13.0" -source = "git+https://github.com/matrix-org/ruma?rev=f25b3220d0c3ece7720020ed180af4955a855402#f25b3220d0c3ece7720020ed180af4955a855402" +source = "git+https://github.com/ruma/ruma?rev=1ae98db9c44f46a590f4c76baf5cef70ebb6970d#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" dependencies = [ "as_variant", "base64", @@ -3215,7 +3174,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.28.1" -source = "git+https://github.com/matrix-org/ruma?rev=f25b3220d0c3ece7720020ed180af4955a855402#f25b3220d0c3ece7720020ed180af4955a855402" +source = "git+https://github.com/ruma/ruma?rev=1ae98db9c44f46a590f4c76baf5cef70ebb6970d#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" dependencies = [ "as_variant", "indexmap", @@ -3240,9 +3199,11 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.9.0" -source = "git+https://github.com/matrix-org/ruma?rev=f25b3220d0c3ece7720020ed180af4955a855402#f25b3220d0c3ece7720020ed180af4955a855402" +source = "git+https://github.com/ruma/ruma?rev=1ae98db9c44f46a590f4c76baf5cef70ebb6970d#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" dependencies = [ + "http", "js_int", + "mime", "ruma-common", "ruma-events", "serde", @@ -3252,7 +3213,7 @@ dependencies = [ [[package]] name = "ruma-html" version = "0.2.0" -source = "git+https://github.com/matrix-org/ruma?rev=f25b3220d0c3ece7720020ed180af4955a855402#f25b3220d0c3ece7720020ed180af4955a855402" +source = "git+https://github.com/ruma/ruma?rev=1ae98db9c44f46a590f4c76baf5cef70ebb6970d#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" dependencies = [ "as_variant", "html5ever", @@ -3264,7 +3225,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.9.5" -source = "git+https://github.com/matrix-org/ruma?rev=f25b3220d0c3ece7720020ed180af4955a855402#f25b3220d0c3ece7720020ed180af4955a855402" +source = "git+https://github.com/ruma/ruma?rev=1ae98db9c44f46a590f4c76baf5cef70ebb6970d#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" dependencies = [ "js_int", "thiserror", @@ -3273,8 +3234,9 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.13.0" -source = "git+https://github.com/matrix-org/ruma?rev=f25b3220d0c3ece7720020ed180af4955a855402#f25b3220d0c3ece7720020ed180af4955a855402" +source = "git+https://github.com/ruma/ruma?rev=1ae98db9c44f46a590f4c76baf5cef70ebb6970d#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" dependencies = [ + "cfg-if", "once_cell", "proc-macro-crate", "proc-macro2", @@ -3287,9 +3249,9 @@ dependencies = [ [[package]] name = "rusqlite" -version = "0.30.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78046161564f5e7cd9008aff3b2990b3850dc8e0349119b98e8f251e099f24d" +checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae" dependencies = [ "bitflags 2.4.1", "fallible-iterator", @@ -3805,26 +3767,25 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -4174,9 +4135,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.5.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" dependencies = [ "getrandom", "wasm-bindgen", @@ -4203,8 +4164,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "vodozemac" version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "051d4af70b53b42adf2aac459a305851b8d754f210aaf11ab509e1065beff422" +source = "git+https://github.com/matrix-org/vodozemac?rev=57cbf7e939d7b54d20207e8361b7135bd65c9cc2#57cbf7e939d7b54d20207e8361b7135bd65c9cc2" dependencies = [ "aes", "arrayvec", @@ -4218,7 +4178,6 @@ dependencies = [ "hkdf", "hmac", "matrix-pickle", - "pkcs7", "prost", "rand", "serde", @@ -4258,19 +4217,20 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", @@ -4295,9 +4255,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4305,9 +4265,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", @@ -4318,9 +4278,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-streams" @@ -4674,17 +4634,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "x509-cert" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25eefca1d99701da3a57feb07e5079fc62abba059fc139e98c13bbb250f3ef29" -dependencies = [ - "const-oid", - "der", - "spki", -] - [[package]] name = "xmlwriter" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 563b53b7..48e47290 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,10 +34,8 @@ futures-util = "0.3" imbl = { version = "3.0.0", features = ["serde"] } # same as matrix-sdk-ui imghdr = "0.7.0" linkify = "0.10.0" -# matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk", default-features = false, features = [ "experimental-sliding-sync", "e2e-encryption", "automatic-room-key-forwarding", "markdown", "sqlite", "rustls-tls", "bundled-sqlite" ] } -matrix-sdk = { git = "https://github.com/project-robius/matrix-rust-sdk", branch = "re-export-reactions-type", default-features = false, features = [ "experimental-sliding-sync", "e2e-encryption", "automatic-room-key-forwarding", "markdown", "sqlite", "rustls-tls", "bundled-sqlite" ] } -# matrix-sdk-ui = { git = "https://github.com/matrix-org/matrix-rust-sdk", default-features = false, features = [ "e2e-encryption", "rustls-tls" ] } -matrix-sdk-ui = { git = "https://github.com/project-robius/matrix-rust-sdk", branch = "re-export-reactions-type", default-features = false, features = [ "e2e-encryption", "rustls-tls" ] } +matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk", default-features = false, features = [ "experimental-sliding-sync", "e2e-encryption", "automatic-room-key-forwarding", "markdown", "sqlite", "rustls-tls", "bundled-sqlite" ] } +matrix-sdk-ui = { git = "https://github.com/matrix-org/matrix-rust-sdk", default-features = false, features = [ "rustls-tls" ] } rand = "0.8.5" rangemap = "1.5.0" serde = "1.0" diff --git a/src/home/room_preview.rs b/src/home/room_preview.rs index 730cfa43..b8212b41 100644 --- a/src/home/room_preview.rs +++ b/src/home/room_preview.rs @@ -40,7 +40,7 @@ live_design! { font_size: 7.5 }, } - text: "[Timestamp unknown]" + text: "??" } MessagePreview = { @@ -48,6 +48,7 @@ live_design! { flow: Down, spacing: 5. latest_message = { + padding: {top: 3.0} html_view = { html = { font_size: 9.3, line_spacing: 1., draw_normal: { text_style: { font_size: 9.3, line_spacing: 1. } }, @@ -60,7 +61,7 @@ live_design! { draw_text: { text_style: { font_size: 9.5, line_spacing: 1. }, } - text: "[Latest message unknown]" + text: "[Loading latest message]" } } } } @@ -301,6 +302,7 @@ impl RoomPreviewContent { live!( html_view = { html = { + font_color: (message_text_color), draw_normal: { color: (message_text_color) }, draw_italic: { color: (message_text_color) }, draw_bold: { color: (message_text_color) }, diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index 518382dc..a1f54fe7 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -1,36 +1,40 @@ //! A room screen is the UI page that displays a single Room's timeline of events/messages //! along with a message input bar at the bottom. -use std::{borrow::Cow, collections::BTreeMap, ops::{DerefMut, Range}, sync::{Arc, Mutex}}; +use std::{borrow::Cow, collections::{BTreeMap, HashMap}, ops::{DerefMut, Range}, sync::{Arc, Mutex}, time::Instant}; use imbl::Vector; use makepad_widgets::*; -use matrix_sdk::{ruma::{ - events::room::{ - message::{ImageMessageEventContent, MessageFormat, MessageType, RoomMessageEventContent, TextMessageEventContent}, MediaSource +use matrix_sdk::{ + ruma::{ + events::room::{ + message::{ + ImageMessageEventContent, MessageFormat, MessageType, RoomMessageEventContent, + TextMessageEventContent, + }, + MediaSource, + }, + matrix_uri::MatrixId, uint, EventId, MatrixToUri, MatrixUri, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, RoomId, UserId }, - matrix_uri::MatrixId, uint, EventId, MatrixToUri, MatrixUri, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, RoomId, UserId -}, OwnedServerName}; + OwnedServerName, +}; use matrix_sdk_ui::timeline::{ - self, EventTimelineItem, MemberProfileChange, Profile, ReactionsByKeyBySender, RepliedToInfo, RoomMembershipChange, - TimelineDetails, TimelineItem, TimelineItemContent, TimelineItemKind, VirtualTimelineItem, + self, EventTimelineItem, MemberProfileChange, Profile, ReactionsByKeyBySender, RepliedToInfo, + RoomMembershipChange, TimelineDetails, TimelineItem, TimelineItemContent, TimelineItemKind, + VirtualTimelineItem, }; use crate::{ - avatar_cache::{self, AvatarCacheEntry}, - event_preview::{text_preview_of_member_profile_change, text_preview_of_other_state, text_preview_of_redacted_message, text_preview_of_room_membership_change, text_preview_of_timeline_item}, - media_cache::{MediaCache, MediaCacheEntry}, - profile::{ + avatar_cache::{self, AvatarCacheEntry}, event_preview::{text_preview_of_member_profile_change, text_preview_of_other_state, text_preview_of_redacted_message, text_preview_of_room_membership_change, text_preview_of_timeline_item}, media_cache::{MediaCache, MediaCacheEntry}, profile::{ user_profile::{AvatarState, ShowUserProfileAction, UserProfile, UserProfileAndRoomId, UserProfilePaneInfo, UserProfileSlidingPaneRef, UserProfileSlidingPaneWidgetExt}, user_profile_cache, - }, - shared::{ + }, shared::{ avatar::{AvatarRef, AvatarWidgetRefExt}, html_or_plaintext::{HtmlOrPlaintextRef, HtmlOrPlaintextWidgetRefExt}, text_or_image::{TextOrImageRef, TextOrImageWidgetRefExt}, + typing_animation::TypingAnimationWidgetExt, }, - sliding_sync::{get_client, submit_async_request, take_timeline_update_receiver, MatrixRequest}, - utils::{self, unix_time_millis_to_datetime, MediaFormatConst}, + sliding_sync::{get_client, submit_async_request, take_timeline_update_receiver, MatrixRequest}, utils::{self, unix_time_millis_to_datetime, MediaFormatConst}, home::room_read_receipt::* }; use rangemap::RangeSet; @@ -48,6 +52,7 @@ live_design! { import crate::shared::html_or_plaintext::*; import crate::home::room_read_receipt::*; import crate::profile::user_profile::UserProfileSlidingPane; + import crate::shared::typing_animation::TypingAnimation; IMG_DEFAULT_AVATAR = dep("crate://self/resources/img/default_avatar.png") ICO_FAV = dep("crate://self/resources/icon_favorite.svg") @@ -210,6 +215,7 @@ live_design! { // A reply preview with a vertical bar drawn in the background. replied_to_message_content = { + cursor: Hand show_bg: true draw_bg: { instance vertical_bar_color: (USERNAME_TEXT_COLOR) @@ -277,12 +283,14 @@ live_design! { visible: false, width: Fill, height: Fit, + padding: {top: 5.0} html_content = { width: Fill, height: Fit, padding: { bottom: 5.0, top: 0.0 }, font_size: 10.5, + font_color: (REACTION_TEXT_COLOR), draw_normal: { color: (REACTION_TEXT_COLOR) }, draw_italic: { color: (REACTION_TEXT_COLOR) }, draw_bold: { color: (REACTION_TEXT_COLOR) }, @@ -355,7 +363,6 @@ live_design! { // A preview of the earlier message that this message was in reply to. replied_to_message = { flow: Right - cursor: Hand margin: { bottom: 5.0, top: 10.0 } replied_to_message_content = { margin: { left: 29 } @@ -630,11 +637,12 @@ live_design! { flow: Overlay, list = { - auto_tail: true, // set to `true` to lock the view to the last item. height: Fill, width: Fill flow: Down + auto_tail: true, // set to `true` to lock the view to the last item. + // Below, we must place all of the possible templates (views) that can be used in the portal list. Message = {} CondensedMessage = {} @@ -787,14 +795,16 @@ live_design! { } typing_label =