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.
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.
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:
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