Commit 4ef69751bc

4ef69751bcd6b01f01f39edffa2b97bdcc9629e2

parent: c53d68494a

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-09-20 19:15 UTC
committer: <noreply@github.com>

Add `sync_delay_ms` option for preventing back-to-back syncs (#723)

Layout: unified · split

config.example.toml +1
@@ -22,6 +22,7 @@ reaction_shortcode_display = false
2222read_receipt_display = true
2323read_receipt_send = true
2424request_timeout = 10000
25sync_delay_ms = 1000
2526typing_notice_display = true
2627typing_notice_send = true
2728user_gutter_width = 30
docs/iamb.5 +3
@@ -277,6 +277,9 @@ See
277277for more details.
278278.It Sy state_event_display
279279Defines whether the state events like joined or left are shown.
280.It Sy sync_delay_ms
281How long to wait after a sync completes before doing the next one.
282Defaults to 250 milliseconds.
280283.It Sy terminal
281284Subsection for configuring how specific terminal features are used (or not used).
282285See
src/config.rs +5
@@ -58,6 +58,7 @@ const DEFAULT_ROOM_SORT: [SortColumn<SortFieldRoom>; 5] = [
5858
5959const DEFAULT_ENABLE_TITLE: bool = true;
6060const DEFAULT_REQ_TIMEOUT: u64 = 120;
61const DEFAULT_SYNC_FREQUENCY: u64 = 250;
6162
6263const DEFAULT_ENC_INDICATOR_LOC: EncryptionIndicatorLocation = EncryptionIndicatorLocation::PROMPT;
6364const DEFAULT_ICON_ENC: Cow<'static, str> = Cow::Borrowed("[E] ");
@@ -849,6 +850,7 @@ pub struct TunableValues {
849850 pub request_timeout: u64,
850851 pub sort: SortValues,
851852 pub state_event_display: bool,
853 pub sync_delay_ms: u64,
852854 pub typing_notice_send: bool,
853855 pub typing_notice_display: bool,
854856 pub users: UserOverrides,
@@ -905,6 +907,7 @@ pub struct Tunables {
905907 pub read_receipt_display: Option<bool>,
906908 pub request_timeout: Option<u64>,
907909 pub state_event_display: Option<bool>,
910 pub sync_delay_ms: Option<u64>,
908911 pub typing_notice_send: Option<bool>,
909912 pub typing_notice_display: Option<bool>,
910913 pub username_display: Option<UserDisplayStyle>,
@@ -957,6 +960,7 @@ impl Tunables {
957960 read_receipt_display: self.read_receipt_display.or(other.read_receipt_display),
958961 request_timeout: self.request_timeout.or(other.request_timeout),
959962 state_event_display: self.state_event_display.or(other.state_event_display),
963 sync_delay_ms: self.sync_delay_ms.or(other.sync_delay_ms),
960964 typing_notice_send: self.typing_notice_send.or(other.typing_notice_send),
961965 typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
962966 username_display: self.username_display.or(other.username_display),
@@ -1002,6 +1006,7 @@ impl Tunables {
10021006 read_receipt_display: self.read_receipt_display.unwrap_or(true),
10031007 request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT),
10041008 state_event_display: self.state_event_display.unwrap_or(true),
1009 sync_delay_ms: self.sync_delay_ms.unwrap_or(DEFAULT_SYNC_FREQUENCY),
10051010 typing_notice_send: self.typing_notice_send.unwrap_or(true),
10061011 typing_notice_display: self.typing_notice_display.unwrap_or(true),
10071012 username_display: self.username_display.unwrap_or_default(),
src/tests.rs +1
@@ -173,6 +173,7 @@ pub fn mock_tunables() -> TunableValues {
173173 request_timeout: 120,
174174 sort: SortOverrides::default().values(),
175175 state_event_display: true,
176 sync_delay_ms: 1000,
176177 terminal: Terminal::default().values(),
177178 typing_notice_send: true,
178179 typing_notice_display: true,
src/worker.rs +2 −1
@@ -1819,11 +1819,12 @@ impl ClientWorker {
18191819 },
18201820 }
18211821
1822 let sync_delay = Duration::from_millis(self.settings.tunables.sync_delay_ms);
18221823 self.sync_handle = tokio::spawn(async move {
18231824 loop {
18241825 let settings = SyncSettings::default();
1825
18261826 let _ = client.sync(settings).await;
1827 tokio::time::sleep(sync_delay).await;
18271828 }
18281829 })
18291830 .into();