Commit 1c1b9f92c0
Unregistered key
Layout: unified · split
docs/iamb.5 +19
| @@ -229,6 +229,25 @@ Defines whether or not reactions should be shown. | ||
| 229 | 229 | Defines whether or not reactions should be shown as their respective shortcode. |
| 230 | 230 | .It Sy read_receipt_send |
| 231 | 231 | Defines whether or not public read confirmations are sent. |
| 232 | .It Sy read_receipt_trigger | |
| 233 | Defines under what conditions threads and rooms are marked read. | |
| 234 | Possible values are: | |
| 235 | .Bl -tag -width Ds | |
| 236 | .It Sy focused | |
| 237 | The room or thread must be focused and scrolled to the last message. | |
| 238 | This is the default value. | |
| 239 | .It Sy visible | |
| 240 | The room or thread must be on screen and scrolled to the last message. | |
| 241 | .It Sy scrollback | |
| 242 | Some portion of the scrollback for the room or thread must be on screen, but | |
| 243 | the room does not need to be scrolled to the last message. | |
| 244 | .It Sy message | |
| 245 | A message must be sent to the room before marking it read. | |
| 246 | .It Sy disabled | |
| 247 | Rooms and threads do not get their read markers updated, and the room | |
| 248 | will remain marked unread until manually cleared or another device updates | |
| 249 | the read marker. | |
| 250 | .El | |
| 232 | 251 | .It Sy read_receipt_display |
| 233 | 252 | Defines whether or not read confirmations are displayed. |
| 234 | 253 | .It Sy request_timeout |
src/base.rs +3 −4
| @@ -93,13 +93,12 @@ use modalkit::{ | ||
| 93 | 93 | prelude::{CommandType, WordStyle}, |
| 94 | 94 | }; |
| 95 | 95 | |
| 96 | use crate::config::ImagePreviewProtocolValues; | |
| 97 | use crate::notifications::NotificationHandle; | |
| 98 | use crate::preview::{source_from_event, PreviewManager}; | |
| 99 | 96 | use crate::{ |
| 97 | config::{ApplicationSettings, ImagePreviewProtocolValues}, | |
| 100 | 98 | message::{Message, MessageEvent, MessageKey, MessageTimeStamp, Messages}, |
| 99 | notifications::NotificationHandle, | |
| 100 | preview::{source_from_event, PreviewManager}, | |
| 101 | 101 | worker::Requester, |
| 102 | ApplicationSettings, | |
| 103 | 102 | }; |
| 104 | 103 | |
| 105 | 104 | /// The set of characters used in different Matrix IDs. |
src/config.rs +40
| @@ -347,6 +347,42 @@ where | ||
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | #[derive(Copy, Clone, Debug, Default, Deserialize, Eq, PartialEq)] | |
| 351 | #[serde(rename_all = "kebab-case")] | |
| 352 | #[repr(u8)] | |
| 353 | pub enum ReadReceiptTrigger { | |
| 354 | /// Update read receipts for a room when a window for it is focused, and it is scrolled to the | |
| 355 | /// last message. | |
| 356 | #[default] | |
| 357 | Focused, | |
| 358 | /// Update read receipts for a room when a window for it is visible, and it is scrolled to the | |
| 359 | /// last message. | |
| 360 | Visible, | |
| 361 | /// Update read receipts for a room whenever some portion of its scrollback is rendered. | |
| 362 | Scrollback, | |
| 363 | /// Update read receipts for a room once the user sends a message to it. | |
| 364 | Message, | |
| 365 | /// Never update read receipts. | |
| 366 | Disabled, | |
| 367 | } | |
| 368 | ||
| 369 | impl ReadReceiptTrigger { | |
| 370 | /// Whether to update read receipts when a room is being rendered. | |
| 371 | pub fn on_render(&self, last_visible: bool, room_focused: bool) -> bool { | |
| 372 | match self { | |
| 373 | Self::Disabled => false, | |
| 374 | Self::Scrollback => true, | |
| 375 | Self::Focused => last_visible && room_focused, | |
| 376 | Self::Visible => last_visible, | |
| 377 | Self::Message => false, | |
| 378 | } | |
| 379 | } | |
| 380 | ||
| 381 | pub fn on_message(&self) -> bool { | |
| 382 | matches!(self, Self::Message) | |
| 383 | } | |
| 384 | } | |
| 385 | ||
| 350 | 386 | #[derive(Copy, Clone, Debug, Default, Deserialize, Eq, PartialEq)] |
| 351 | 387 | #[serde(rename_all = "kebab-case")] |
| 352 | 388 | #[repr(u8)] |
| @@ -763,6 +799,7 @@ pub struct TunableValues { | ||
| 763 | 799 | pub reaction_display: bool, |
| 764 | 800 | pub reaction_shortcode_display: bool, |
| 765 | 801 | pub read_receipt_send: bool, |
| 802 | pub read_receipt_trigger: ReadReceiptTrigger, | |
| 766 | 803 | pub read_receipt_display: bool, |
| 767 | 804 | pub request_timeout: u64, |
| 768 | 805 | pub sort: SortValues, |
| @@ -812,6 +849,7 @@ pub struct Tunables { | ||
| 812 | 849 | pub reaction_display: Option<bool>, |
| 813 | 850 | pub reaction_shortcode_display: Option<bool>, |
| 814 | 851 | pub read_receipt_send: Option<bool>, |
| 852 | pub read_receipt_trigger: Option<ReadReceiptTrigger>, | |
| 815 | 853 | pub read_receipt_display: Option<bool>, |
| 816 | 854 | pub request_timeout: Option<u64>, |
| 817 | 855 | pub state_event_display: Option<bool>, |
| @@ -855,6 +893,7 @@ impl Tunables { | ||
| 855 | 893 | .reaction_shortcode_display |
| 856 | 894 | .or(other.reaction_shortcode_display), |
| 857 | 895 | read_receipt_send: self.read_receipt_send.or(other.read_receipt_send), |
| 896 | read_receipt_trigger: self.read_receipt_trigger.or(other.read_receipt_trigger), | |
| 858 | 897 | read_receipt_display: self.read_receipt_display.or(other.read_receipt_display), |
| 859 | 898 | request_timeout: self.request_timeout.or(other.request_timeout), |
| 860 | 899 | state_event_display: self.state_event_display.or(other.state_event_display), |
| @@ -892,6 +931,7 @@ impl Tunables { | ||
| 892 | 931 | reaction_display: self.reaction_display.unwrap_or(true), |
| 893 | 932 | reaction_shortcode_display: self.reaction_shortcode_display.unwrap_or(false), |
| 894 | 933 | read_receipt_send: self.read_receipt_send.unwrap_or(true), |
| 934 | read_receipt_trigger: self.read_receipt_trigger.unwrap_or_default(), | |
| 895 | 935 | read_receipt_display: self.read_receipt_display.unwrap_or(true), |
| 896 | 936 | request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT), |
| 897 | 937 | state_event_display: self.state_event_display.unwrap_or(true), |
src/tests.rs +1
| @@ -176,6 +176,7 @@ pub fn mock_tunables() -> TunableValues { | ||
| 176 | 176 | reaction_display: true, |
| 177 | 177 | reaction_shortcode_display: false, |
| 178 | 178 | read_receipt_send: true, |
| 179 | read_receipt_trigger: Default::default(), | |
| 179 | 180 | read_receipt_display: true, |
| 180 | 181 | request_timeout: 120, |
| 181 | 182 | sort: SortOverrides::default().values(), |
src/windows/room/chat.rs +8
| @@ -564,6 +564,8 @@ impl ChatState { | ||
| 564 | 564 | _: ProgramContext, |
| 565 | 565 | store: &mut ProgramStore, |
| 566 | 566 | ) -> IambResult<EditInfo> { |
| 567 | let settings = &store.application.settings; | |
| 568 | let tunables = &settings.tunables; | |
| 567 | 569 | let room = self.get_joined(&store.application.worker)?; |
| 568 | 570 | let info = store.application.rooms.get_or_default(self.id().to_owned()); |
| 569 | 571 | |
| @@ -692,6 +694,12 @@ impl ChatState { | ||
| 692 | 694 | // Jump to the end of the scrollback to show the message. |
| 693 | 695 | self.scrollback.goto_latest(); |
| 694 | 696 | |
| 697 | if tunables.read_receipt_trigger.on_message() { | |
| 698 | if let Some(thread) = self.scrollback.get_thread(info) { | |
| 699 | info.fully_read(settings.profile.user_id.clone(), thread.1.clone()); | |
| 700 | } | |
| 701 | } | |
| 702 | ||
| 695 | 703 | Ok(None) |
| 696 | 704 | } |
| 697 | 705 | |
src/windows/room/scrollback.rs +6 −2
| @@ -1459,8 +1459,12 @@ impl StatefulWidget for Scrollback<'_> { | ||
| 1459 | 1459 | } |
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | if self.room_focused && state.cursor.timestamp.is_none() { | |
| 1463 | // If the cursor is at the last message, then update the read marker. | |
| 1462 | // Check if we should update the user's read receipt for this room after this render: | |
| 1463 | if settings | |
| 1464 | .tunables | |
| 1465 | .read_receipt_trigger | |
| 1466 | .on_render(state.cursor.timestamp.is_none(), self.room_focused) | |
| 1467 | { | |
| 1464 | 1468 | info.fully_read(settings.profile.user_id.clone(), thread.1.clone()); |
| 1465 | 1469 | } |
| 1466 | 1470 | |