Commit c420c9dd65
c420c9dd65b9e95dd9163ffe1fc214c95fb04762
parent: ba7d0392d8
Unregistered key
Ulyssa <git@ulyssa.dev> · 2025-06-05 02:36 UTC
committer: <noreply@github.com>
Add configuration option for hiding state events (#447)
Layout: unified · split
src/config.rs
+4
| @@ -561,6 +561,7 @@ pub struct TunableValues { |
| 561 | 561 | pub read_receipt_display: bool, |
| 562 | 562 | pub request_timeout: u64, |
| 563 | 563 | pub sort: SortValues, |
| 564 | pub state_event_display: bool, |
| 564 | 565 | pub typing_notice_send: bool, |
| 565 | 566 | pub typing_notice_display: bool, |
| 566 | 567 | pub users: UserOverrides, |
| @@ -586,6 +587,7 @@ pub struct Tunables { |
| 586 | 587 | pub request_timeout: Option<u64>, |
| 587 | 588 | #[serde(default)] |
| 588 | 589 | pub sort: SortOverrides, |
| 590 | pub state_event_display: Option<bool>, |
| 589 | 591 | pub typing_notice_send: Option<bool>, |
| 590 | 592 | pub typing_notice_display: Option<bool>, |
| 591 | 593 | pub users: Option<UserOverrides>, |
| @@ -615,6 +617,7 @@ impl Tunables { |
| 615 | 617 | read_receipt_display: self.read_receipt_display.or(other.read_receipt_display), |
| 616 | 618 | request_timeout: self.request_timeout.or(other.request_timeout), |
| 617 | 619 | sort: merge_sorts(self.sort, other.sort), |
| 620 | state_event_display: self.state_event_display.or(other.state_event_display), |
| 618 | 621 | typing_notice_send: self.typing_notice_send.or(other.typing_notice_send), |
| 619 | 622 | typing_notice_display: self.typing_notice_display.or(other.typing_notice_display), |
| 620 | 623 | users: merge_maps(self.users, other.users), |
| @@ -642,6 +645,7 @@ impl Tunables { |
| 642 | 645 | read_receipt_display: self.read_receipt_display.unwrap_or(true), |
| 643 | 646 | request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT), |
| 644 | 647 | sort: self.sort.values(), |
| 648 | state_event_display: self.state_event_display.unwrap_or(true), |
| 645 | 649 | typing_notice_send: self.typing_notice_send.unwrap_or(true), |
| 646 | 650 | typing_notice_display: self.typing_notice_display.unwrap_or(true), |
| 647 | 651 | users: self.users.unwrap_or_default(), |
src/tests.rs
+1
| @@ -177,6 +177,7 @@ pub fn mock_tunables() -> TunableValues { |
| 177 | 177 | read_receipt_display: true, |
| 178 | 178 | request_timeout: 120, |
| 179 | 179 | sort: SortOverrides::default().values(), |
| 180 | state_event_display: true, |
| 180 | 181 | typing_notice_send: true, |
| 181 | 182 | typing_notice_display: true, |
| 182 | 183 | users: vec![(TEST_USER5.clone(), UserDisplayTunables { |
src/worker.rs
+15 −11
| @@ -362,7 +362,9 @@ fn load_insert( |
| 362 | 362 | continue; |
| 363 | 363 | }, |
| 364 | 364 | AnyTimelineEvent::State(msg) => { |
| 365 | | info.insert_any_state(msg.into()); |
| 365 | if settings.tunables.state_event_display { |
| 366 | info.insert_any_state(msg.into()); |
| 367 | } |
| 366 | 368 | }, |
| 367 | 369 | } |
| 368 | 370 | } |
| @@ -1059,17 +1061,19 @@ impl ClientWorker { |
| 1059 | 1061 | }, |
| 1060 | 1062 | ); |
| 1061 | 1063 | |
| 1062 | | let _ = self.client.add_event_handler( |
| 1063 | | |ev: AnySyncStateEvent, room: MatrixRoom, store: Ctx<AsyncProgramStore>| { |
| 1064 | | async move { |
| 1065 | | let room_id = room.room_id(); |
| 1066 | | let mut locked = store.lock().await; |
| 1064 | if self.settings.tunables.state_event_display { |
| 1065 | let _ = self.client.add_event_handler( |
| 1066 | |ev: AnySyncStateEvent, room: MatrixRoom, store: Ctx<AsyncProgramStore>| { |
| 1067 | async move { |
| 1068 | let room_id = room.room_id(); |
| 1069 | let mut locked = store.lock().await; |
| 1067 | 1070 | |
| 1068 | | let info = locked.application.get_room_info(room_id.to_owned()); |
| 1069 | | info.insert_any_state(ev); |
| 1070 | | } |
| 1071 | | }, |
| 1072 | | ); |
| 1071 | let info = locked.application.get_room_info(room_id.to_owned()); |
| 1072 | info.insert_any_state(ev); |
| 1073 | } |
| 1074 | }, |
| 1075 | ); |
| 1076 | } |
| 1073 | 1077 | |
| 1074 | 1078 | let _ = self.client.add_event_handler( |
| 1075 | 1079 | |ev: OriginalSyncRoomRedactionEvent, |