mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-19 21:29:52 -07:00
Add configuration option for hiding state events (#447)
This commit is contained in:
parent
ba7d0392d8
commit
c420c9dd65
3 changed files with 20 additions and 11 deletions
|
@ -561,6 +561,7 @@ pub struct TunableValues {
|
||||||
pub read_receipt_display: bool,
|
pub read_receipt_display: bool,
|
||||||
pub request_timeout: u64,
|
pub request_timeout: u64,
|
||||||
pub sort: SortValues,
|
pub sort: SortValues,
|
||||||
|
pub state_event_display: bool,
|
||||||
pub typing_notice_send: bool,
|
pub typing_notice_send: bool,
|
||||||
pub typing_notice_display: bool,
|
pub typing_notice_display: bool,
|
||||||
pub users: UserOverrides,
|
pub users: UserOverrides,
|
||||||
|
@ -586,6 +587,7 @@ pub struct Tunables {
|
||||||
pub request_timeout: Option<u64>,
|
pub request_timeout: Option<u64>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub sort: SortOverrides,
|
pub sort: SortOverrides,
|
||||||
|
pub state_event_display: Option<bool>,
|
||||||
pub typing_notice_send: Option<bool>,
|
pub typing_notice_send: Option<bool>,
|
||||||
pub typing_notice_display: Option<bool>,
|
pub typing_notice_display: Option<bool>,
|
||||||
pub users: Option<UserOverrides>,
|
pub users: Option<UserOverrides>,
|
||||||
|
@ -615,6 +617,7 @@ impl Tunables {
|
||||||
read_receipt_display: self.read_receipt_display.or(other.read_receipt_display),
|
read_receipt_display: self.read_receipt_display.or(other.read_receipt_display),
|
||||||
request_timeout: self.request_timeout.or(other.request_timeout),
|
request_timeout: self.request_timeout.or(other.request_timeout),
|
||||||
sort: merge_sorts(self.sort, other.sort),
|
sort: merge_sorts(self.sort, other.sort),
|
||||||
|
state_event_display: self.state_event_display.or(other.state_event_display),
|
||||||
typing_notice_send: self.typing_notice_send.or(other.typing_notice_send),
|
typing_notice_send: self.typing_notice_send.or(other.typing_notice_send),
|
||||||
typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
|
typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
|
||||||
users: merge_maps(self.users, other.users),
|
users: merge_maps(self.users, other.users),
|
||||||
|
@ -642,6 +645,7 @@ impl Tunables {
|
||||||
read_receipt_display: self.read_receipt_display.unwrap_or(true),
|
read_receipt_display: self.read_receipt_display.unwrap_or(true),
|
||||||
request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT),
|
request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT),
|
||||||
sort: self.sort.values(),
|
sort: self.sort.values(),
|
||||||
|
state_event_display: self.state_event_display.unwrap_or(true),
|
||||||
typing_notice_send: self.typing_notice_send.unwrap_or(true),
|
typing_notice_send: self.typing_notice_send.unwrap_or(true),
|
||||||
typing_notice_display: self.typing_notice_display.unwrap_or(true),
|
typing_notice_display: self.typing_notice_display.unwrap_or(true),
|
||||||
users: self.users.unwrap_or_default(),
|
users: self.users.unwrap_or_default(),
|
||||||
|
|
|
@ -177,6 +177,7 @@ pub fn mock_tunables() -> TunableValues {
|
||||||
read_receipt_display: true,
|
read_receipt_display: true,
|
||||||
request_timeout: 120,
|
request_timeout: 120,
|
||||||
sort: SortOverrides::default().values(),
|
sort: SortOverrides::default().values(),
|
||||||
|
state_event_display: true,
|
||||||
typing_notice_send: true,
|
typing_notice_send: true,
|
||||||
typing_notice_display: true,
|
typing_notice_display: true,
|
||||||
users: vec![(TEST_USER5.clone(), UserDisplayTunables {
|
users: vec![(TEST_USER5.clone(), UserDisplayTunables {
|
||||||
|
|
|
@ -362,7 +362,9 @@ fn load_insert(
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
AnyTimelineEvent::State(msg) => {
|
AnyTimelineEvent::State(msg) => {
|
||||||
|
if settings.tunables.state_event_display {
|
||||||
info.insert_any_state(msg.into());
|
info.insert_any_state(msg.into());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1059,6 +1061,7 @@ impl ClientWorker {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if self.settings.tunables.state_event_display {
|
||||||
let _ = self.client.add_event_handler(
|
let _ = self.client.add_event_handler(
|
||||||
|ev: AnySyncStateEvent, room: MatrixRoom, store: Ctx<AsyncProgramStore>| {
|
|ev: AnySyncStateEvent, room: MatrixRoom, store: Ctx<AsyncProgramStore>| {
|
||||||
async move {
|
async move {
|
||||||
|
@ -1070,6 +1073,7 @@ impl ClientWorker {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let _ = self.client.add_event_handler(
|
let _ = self.client.add_event_handler(
|
||||||
|ev: OriginalSyncRoomRedactionEvent,
|
|ev: OriginalSyncRoomRedactionEvent,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue