From 2bf5b1a5d5002733cda898f749a14219e40ba301 Mon Sep 17 00:00:00 2001 From: Alexandre Franke Date: Wed, 14 Apr 2021 19:05:19 +0200 Subject: [PATCH] filter: apply to all sync requests --- fractal-gtk/src/backend/sync.rs | 50 +++++++++++++++------------------ 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/fractal-gtk/src/backend/sync.rs b/fractal-gtk/src/backend/sync.rs index 93bbd930..84d68d44 100644 --- a/fractal-gtk/src/backend/sync.rs +++ b/fractal-gtk/src/backend/sync.rs @@ -64,43 +64,39 @@ pub async fn sync( since: Option, number_tries: u32, ) -> Result { - let initial = since.is_none(); let timeline_not_types = [String::from("m.call.*")]; let timeline_types = [String::from("m.room.message"), String::from("m.sticker")]; let state_types = [String::from("m.room.*")]; - let sync_settings = if !initial { - SyncSettings::new().timeout(Duration::from_secs(30)) - } else { - // Don't filter event fields, it breaks deserialization. - // Clearly the Matrix API is very static-typing-unfriendly right now. - let filter = assign!(FilterDefinition::empty(), { - presence: assign!(EventFilter::empty(), { + + // Don't filter event fields, it breaks deserialization. + // Clearly the Matrix API is very static-typing-unfriendly right now. + let filter = assign!(FilterDefinition::empty(), { + presence: assign!(EventFilter::empty(), { + types: Some(&[]), + }), + room: assign!(RoomFilter::empty(), { + timeline: assign!(RoomEventFilter::empty(), { + not_types: &timeline_not_types, + limit: Some(globals::PAGE_LIMIT.into()), + types: Some(&timeline_types), + }), + ephemeral: assign!(RoomEventFilter::empty(), { types: Some(&[]), }), - room: assign!(RoomFilter::empty(), { - timeline: assign!(RoomEventFilter::empty(), { - not_types: &timeline_not_types, - limit: Some(globals::PAGE_LIMIT.into()), - types: Some(&timeline_types), - }), - ephemeral: assign!(RoomEventFilter::empty(), { - types: Some(&[]), - }), - state: assign!(RoomEventFilter::empty(), { - types: Some(&state_types), - lazy_load_options: LazyLoadOptions::Enabled { - include_redundant_members: false, - }, - }), + state: assign!(RoomEventFilter::empty(), { + types: Some(&state_types), + lazy_load_options: LazyLoadOptions::Enabled { + include_redundant_members: false, + }, }), - }); + }), + }); - SyncSettings::new().filter(Filter::FilterDefinition(filter)) - }; + let sync_settings = SyncSettings::new().filter(Filter::FilterDefinition(filter)); let sync_settings = match since.clone() { Some(sync_token) => sync_settings.token(sync_token), - None => sync_settings, + None => sync_settings.timeout(Duration::from_secs(30)), }; match session_client.sync_once(sync_settings).await {