linagora / twake-on-matrix

A multi-platform (Flutter) application for connecting to Matrix - an open network for secure, decentralized communication, with your favorite devices.
GNU Affero General Public License v3.0
26 stars 7 forks source link

TW-1675: status of user is not correct #1684

Closed Te-Z closed 1 month ago

Te-Z commented 1 month ago

Issue:

https://github.com/linagora/twake-on-matrix/issues/1675

Root cause:

The root cause was in matrix-dart-sdk. Here is the copy paste of the explanation I made there:

This was the previous code: https://github.com/linagora/matrix-dart-sdk/blob/e0b65295255b852532878a948662920d6963cc6f/lib/src/client.dart#L1793-L1799

The UI previously listened to onPresenceChanged which is a CachedStreamController . This instance had a new value added in the for each loop for every items in sync.presencelist. This means if there's different values in sync.presence , the UI will be updated 6 times.

To handle that I changed for this code:

https://github.com/linagora/matrix-dart-sdk/blob/b0c34117c60360d3f1241af9653ddaaa88aaead4/lib/src/client.dart#L1809-L1829

Here lowestLastActivePresence is updated for each items in sync.presence list if it is null or if the current item's timestamp is before the one in lowestLastActivePresence. Then when the loop is over and we are sure to have the right value, we can update onLatestPresenceChange with the right value and this way update the UI.

Warning:

Merge https://github.com/linagora/matrix-dart-sdk/pull/54 before this one

Demo:

Capture vidéo du 04-04-2024 14:20:22.webm

https://github.com/linagora/twake-on-matrix/assets/31937920/2ef61a81-6278-4771-aca5-3b938559ec4f

github-actions[bot] commented 1 month ago

This PR has been deployed to https://linagora.github.io/twake-on-matrix/1684

hoangdat commented 1 month ago