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 {
561561 pub read_receipt_display: bool,
562562 pub request_timeout: u64,
563563 pub sort: SortValues,
564 pub state_event_display: bool,
564565 pub typing_notice_send: bool,
565566 pub typing_notice_display: bool,
566567 pub users: UserOverrides,
@@ -586,6 +587,7 @@ pub struct Tunables {
586587 pub request_timeout: Option<u64>,
587588 #[serde(default)]
588589 pub sort: SortOverrides,
590 pub state_event_display: Option<bool>,
589591 pub typing_notice_send: Option<bool>,
590592 pub typing_notice_display: Option<bool>,
591593 pub users: Option<UserOverrides>,
@@ -615,6 +617,7 @@ impl Tunables {
615617 read_receipt_display: self.read_receipt_display.or(other.read_receipt_display),
616618 request_timeout: self.request_timeout.or(other.request_timeout),
617619 sort: merge_sorts(self.sort, other.sort),
620 state_event_display: self.state_event_display.or(other.state_event_display),
618621 typing_notice_send: self.typing_notice_send.or(other.typing_notice_send),
619622 typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
620623 users: merge_maps(self.users, other.users),
@@ -642,6 +645,7 @@ impl Tunables {
642645 read_receipt_display: self.read_receipt_display.unwrap_or(true),
643646 request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT),
644647 sort: self.sort.values(),
648 state_event_display: self.state_event_display.unwrap_or(true),
645649 typing_notice_send: self.typing_notice_send.unwrap_or(true),
646650 typing_notice_display: self.typing_notice_display.unwrap_or(true),
647651 users: self.users.unwrap_or_default(),
src/tests.rs +1
@@ -177,6 +177,7 @@ pub fn mock_tunables() -> TunableValues {
177177 read_receipt_display: true,
178178 request_timeout: 120,
179179 sort: SortOverrides::default().values(),
180 state_event_display: true,
180181 typing_notice_send: true,
181182 typing_notice_display: true,
182183 users: vec![(TEST_USER5.clone(), UserDisplayTunables {
src/worker.rs +15 −11
@@ -362,7 +362,9 @@ fn load_insert(
362362 continue;
363363 },
364364 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 }
366368 },
367369 }
368370 }
@@ -1059,17 +1061,19 @@ impl ClientWorker {
10591061 },
10601062 );
10611063
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;
10671070
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 }
10731077
10741078 let _ = self.client.add_event_handler(
10751079 |ev: OriginalSyncRoomRedactionEvent,