Commit ad8b4a60d2
Unregistered key
Layout: unified · split
src/base.rs +5 −6
| @@ -666,7 +666,10 @@ impl ChatStore { | ||
| 666 | 666 | .unwrap_or_else(|| "Untitled Matrix Room".to_string()) |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | pub async fn set_receipts(&mut self, receipts: Vec<(OwnedRoomId, Receipts)>) { | |
| 669 | pub async fn set_receipts( | |
| 670 | &mut self, | |
| 671 | receipts: Vec<(OwnedRoomId, Receipts)>, | |
| 672 | ) -> Vec<(OwnedRoomId, OwnedEventId)> { | |
| 670 | 673 | let mut updates = vec![]; |
| 671 | 674 | |
| 672 | 675 | for (room_id, receipts) in receipts.into_iter() { |
| @@ -679,11 +682,7 @@ impl ChatStore { | ||
| 679 | 682 | } |
| 680 | 683 | } |
| 681 | 684 | |
| 682 | for (room_id, read_till) in updates.into_iter() { | |
| 683 | if let Some(room) = self.worker.client.get_joined_room(&room_id) { | |
| 684 | let _ = room.read_receipt(read_till.as_ref()).await; | |
| 685 | } | |
| 686 | } | |
| 685 | return updates; | |
| 687 | 686 | } |
| 688 | 687 | |
| 689 | 688 | pub fn mark_for_load(&mut self, room_id: OwnedRoomId) { |
src/worker.rs +18 −1
| @@ -56,6 +56,7 @@ use matrix_sdk::{ | ||
| 56 | 56 | room::RoomType, |
| 57 | 57 | serde::Raw, |
| 58 | 58 | EventEncryptionAlgorithm, |
| 59 | OwnedEventId, | |
| 59 | 60 | OwnedRoomId, |
| 60 | 61 | OwnedRoomOrAliasId, |
| 61 | 62 | OwnedUserId, |
| @@ -905,6 +906,7 @@ impl ClientWorker { | ||
| 905 | 906 | self.rcpt_handle = tokio::spawn({ |
| 906 | 907 | let store = store.clone(); |
| 907 | 908 | let client = self.client.clone(); |
| 909 | let mut sent = HashMap::<OwnedRoomId, OwnedEventId>::default(); | |
| 908 | 910 | |
| 909 | 911 | async move { |
| 910 | 912 | // Update the displayed read receipts every 5 seconds. |
| @@ -914,7 +916,22 @@ impl ClientWorker { | ||
| 914 | 916 | interval.tick().await; |
| 915 | 917 | |
| 916 | 918 | let receipts = update_receipts(&client).await; |
| 917 | store.lock().await.application.set_receipts(receipts).await; | |
| 919 | let read = store.lock().await.application.set_receipts(receipts).await; | |
| 920 | ||
| 921 | for (room_id, read_till) in read.into_iter() { | |
| 922 | if let Some(read_sent) = sent.get(&room_id) { | |
| 923 | if read_sent == &read_till { | |
| 924 | // Skip unchanged receipts. | |
| 925 | continue; | |
| 926 | } | |
| 927 | } | |
| 928 | ||
| 929 | if let Some(room) = client.get_joined_room(&room_id) { | |
| 930 | if room.read_receipt(&read_till).await.is_ok() { | |
| 931 | sent.insert(room_id, read_till); | |
| 932 | } | |
| 933 | } | |
| 934 | } | |
| 918 | 935 | } |
| 919 | 936 | } |
| 920 | 937 | }) |