feat(sliding-sync): allow configuring sync presence#6672
Conversation
Signed-off-by: Jared L <48422312+lhjt@users.noreply.github.com>
Signed-off-by: Jared L <48422312+lhjt@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6672 +/- ##
==========================================
- Coverage 89.89% 89.89% -0.01%
==========================================
Files 396 396
Lines 110264 110412 +148
Branches 110264 110412 +148
==========================================
+ Hits 99117 99250 +133
+ Misses 7376 7375 -1
- Partials 3771 3787 +16 ☔ View full report in Codecov by Harness. |
stefanceriu
left a comment
There was a problem hiding this comment.
Hello, thank you for raising this!
I've conferred with my coleagues and we believe this isn't really the right approach, the RoomListService shouldn't expose any interfaces into the underlying sliding sync or even mention it really, its only responsibility is and should be to deal with well .. room lists.
We think a better avenue would be to expose this on the client itself, where SlidingSync would read the value from when generating a sync request.
|
Hi @stefanceriu, thanks so much for the review! I wholly agree with the sentiment above; my initial goal was to bring idle status on suspend to element x, and ensuring background sync in element x wouldn't set the user's presence to online (in an effort to help improve the push notification experience within the matrix ecosystem) I'll update this PR accordingly 🙂 |
Signed-off-by: Jared L <48422312+lhjt@users.noreply.github.com>
|
I was checking your changes and I think this could maybe be simplified further? In With this you wouldn't have to duplicate the presence property and set/clear methods in Also, maybe instead of having several |
That sounds great, thanks for looking into it!
All if it makes sense to me, thanks for reviewing Jorge. |
Signed-off-by: Jared L <48422312+lhjt@users.noreply.github.com>
|
Thanks for the review @jmartinesp (and @stefanceriu)! I have updated the PR to simplify this down further as per your recommendation 🙂 Regarding
I figured maintaining those as separate methods would be more explicit (though I am happy to collapse them behind a single API if you’d still prefer that signature) |
To be honest I think and |
|
Sure thing; I'll update it |
Signed-off-by: Jared L <48422312+lhjt@users.noreply.github.com>
Signed-off-by: Jared L <48422312+lhjt@users.noreply.github.com>
stefanceriu
left a comment
There was a problem hiding this comment.
Looking good but I did leave some more comments inline. Thank you!
Signed-off-by: Jared L <48422312+lhjt@users.noreply.github.com>
Signed-off-by: Jared L <48422312+lhjt@users.noreply.github.com>
Signed-off-by: Jared L <48422312+lhjt@users.noreply.github.com>
Signed-off-by: Stefan Ceriu <stefanc@matrix.org>
stefanceriu
left a comment
There was a problem hiding this comment.
Great, thank you very much for the contribution! 🙏
Allow sliding sync clients to configure the
set_presencevalue sent with generated sync requests.This adds presence configuration to
SlidingSyncBuilder, stores it onSlidingSync, and exposesSlidingSync::set_presencefor runtime updates. The UI sync helpers now thread the same presence setting through both the room-list sync and encryption sync services, so background sync users can requestofflineorunavailablepresence instead of being marked online by polling.The default remains
PresenceState::Online, matching the Matrix sync API default and preserving existing behaviour.API shape
The core
SlidingSyncBuilder::set_presenceandSyncServiceBuilder::with_presenceAPIs follow the existing builder style.RoomListService::new_with_presenceandEncryptionSyncService::new_with_presenceare added to keep the existing public constructors backwards-compatible while allowing callers to configure presence at construction time.I would be happy to refactor this into a dedicated builder or options struct for
RoomListServiceandEncryptionSyncService, which would likely scale better than adding morenew_with_*constructors (if this is something the maintainers would prefer).Tests
cargo test -p matrix-sdk test_sliding_sync_request_uses_configured_presence --libcargo test -p matrix-sdk-ui --test integration test_sync_service_presence_is_used_by_both_syncscargo fmt --checkcurrently fails on an unrelated upstream formatting difference incrates/matrix-sdk/src/event_cache/redecryptor.rs.