Skip to content

Conversation

aringenbach
Copy link
Contributor

Fixes #6144

Open to discussion around this solution :)

Advantages:

  • Built around already in place Presence NSNotification solution
  • Doesn't require reloadData anytime someone's Presence updates

Drawback:

  • Adds a bit of intelligence inside cells

The other solution would require a few changes on both application and SDK, including :

  • Storing a directUserPresence on MXRoomSummaryMO so the fetchers can trigger room list updates accordingly
  • Having a way smarter approach towards table view / collection view updates for Home & DM

@aringenbach aringenbach requested review from a team, Anderas and pixlwave and removed request for a team May 11, 2022 13:36
{
// Observe contact presence change
MXWeakify(self);
mxDirectUserPresenceObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXKContactManagerMatrixUserPresenceChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to pass the directUserId in as the object to reduce the number of times this block will get called? As a bonus, if the ID is nil, the observer wouldn't even need to be created.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately this doesn't seem to work I suppose it has to be the same object rather than two objects that happen to be equal.

Copy link
Member

Choose a reason for hiding this comment

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

Ah that's a shame, but also seems obvious now you mention it 🤦‍♂️

Copy link
Member

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

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

Yeah, fundamentally I'd say using the existing notification system seems like the right thing from my perspective.

As a potential alternative for the cell having some logic, would it make sense to extract the listener logic into an object owned by the presence view? It could be more reusable that way and work automatically if the indicator is added elsewhere in the future.

@aringenbach
Copy link
Contributor Author

Yeah, fundamentally I'd say using the existing notification system seems like the right thing from my perspective.

As a potential alternative for the cell having some logic, would it make sense to extract the listener logic into an object owned by the presence view? It could be more reusable that way and work automatically if the indicator is added elsewhere in the future.

Yeah I suppose this makes sense and would avoid some code repetition as well.

@aringenbach aringenbach requested a review from pixlwave May 12, 2022 09:03
@github-actions
Copy link

📱 Scan the QR code below to install the build for this PR.
🔒 This build is for internal testing purpose. Only devices listed in the ad-hoc provisioning profile can install Element Alpha.

QR code

If you can't scan the QR code you can install the build via this link: https://i.diawi.com/kbz5vG

Copy link
Member

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@aringenbach aringenbach merged commit 64d9824 into develop May 12, 2022
@aringenbach aringenbach deleted the aringenbach/6144_presence_home_dm_refresh branch May 12, 2022 14:19
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.

Presence status doesn't update live on Home & DM list

3 participants