Skip to content

feat: Implement App API #2204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 11, 2023
Merged

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jul 3, 2023

This implements a very high-level App API that takes care of all the sliding syncs:

  • if configured with with_encryption_sync, then it will spawn two sliding syncs, one for the room list, one for e2ee. It can be configured to run with the cross-process crypto store lock or not (for the needs of Element X iOS).
  • if not, it will run a single sliding sync that powers both the room list and e2ee.

Fixes #1928.

This is based on top of #2235, as the final commits get rid of ways to manually create (and misconfigure) EncryptionSync and the RoomListService \o/

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, I think all of it makes sense. If we can remove the ability to disable E2EE on the main client, that would be even better.

self
}

pub fn with_encryption_sync(mut self) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the Matrix room, do we need this? Can't we make it always true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's needed until we enable the encryption sync by default... which should be the case any time now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, once we do that, please let us remove this as well.


pub struct App {
room_list: Arc<RoomListService>,
encryption_sync: Option<Arc<EncryptionSync>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're always going to have an EncryptionSync then we don't need an optional here. We could #[cfg(feature = "e2e-encryption")] this field if we want to support clients that don't use E2EE.

// and the loop to terminate.

loop {
tokio::select! {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of a select!.

@bnjbvr bnjbvr force-pushed the better-get-notification-api branch from 8e286f9 to a24495a Compare July 7, 2023 13:23
@bnjbvr bnjbvr changed the title feat: Implement App and NotificationClient APIs feat: Implement App API Jul 7, 2023
@Velin92
Copy link
Member

Velin92 commented Jul 10, 2023

Tested and works pretty well on the iOS side, makes the code easier to read a decouples a lot of responsibilities from the client, love it!

@bnjbvr bnjbvr force-pushed the better-get-notification-api branch from a24495a to cc92444 Compare July 10, 2023 17:40
@bnjbvr bnjbvr marked this pull request as ready for review July 10, 2023 17:40
@bnjbvr bnjbvr requested a review from a team as a code owner July 10, 2023 17:40
@bnjbvr bnjbvr requested review from jplatte and poljar and removed request for a team and jplatte July 10, 2023 17:40
@bnjbvr
Copy link
Member Author

bnjbvr commented Jul 10, 2023

Thanks a bunch Mauro for trying it 🥳

This is now ready for review, since the NotificationClient API has been merged. I haven't included any proper tests for App here, since they would mostly repeat what the room list and/or encryption sync do, but I could add some if you have any ideas for specific tests.

I still am not fond of the App name: IMO it's too generic, and doesn't quite describe what this does. How about any of the following: SyncService / SyncLoops / Synchronizer (lol) / SyncLoopService? (or anything else that tells it's doing some syncs)

@codecov
Copy link

codecov bot commented Jul 10, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.09 ⚠️

Comparison is base (879d1b1) 76.73% compared to head (cc92444) 76.64%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2204      +/-   ##
==========================================
- Coverage   76.73%   76.64%   -0.09%     
==========================================
  Files         172      173       +1     
  Lines       18060    18081      +21     
==========================================
  Hits        13858    13858              
- Misses       4202     4223      +21     
Impacted Files Coverage Δ
crates/matrix-sdk-ui/src/app/mod.rs 0.00% <0.00%> (ø)
crates/matrix-sdk-ui/src/lib.rs 100.00% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Not a fan of the App name either, but we can bikeshed later on.

@bnjbvr bnjbvr merged commit 43bbd42 into matrix-org:main Jul 11, 2023
@bnjbvr bnjbvr deleted the better-get-notification-api branch July 11, 2023 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sliding sync: The Two Sync Loops
3 participants