Handle use only latest profile live refreshes

This commit is contained in:
Arnaud Ringenbach
2022-03-02 15:51:01 +01:00
committed by aringenbach
parent a6ed656107
commit 91d3411326
3 changed files with 45 additions and 0 deletions
@@ -34,6 +34,8 @@
#import "MXKSendReplyEventStringLocalizer.h"
#import "MXKSlashCommands.h"
#import "GeneratedInterface-Swift.h"
const BOOL USE_THREAD_TIMELINE = YES;
#pragma mark - Constant definitions
@@ -1009,6 +1011,11 @@ typedef NS_ENUM (NSUInteger, MXKRoomDataSourceError) {
liveEventsListener = [_timeline listenToEventsOfTypes:liveEventTypesFilterForMessages onEvent:^(MXEvent *event, MXTimelineDirection direction, MXRoomState *roomState) {
MXStrongifyAndReturnIfNil(self);
if (RiotSettings.shared.roomScreenUseOnlyLatestProfiles && event.eventType == MXEventTypeRoomMember && event.isUserProfileChange)
{
[self refreshProfilesIfNeeded];
}
if (MXTimelineDirectionForwards == direction)
{
@@ -4321,4 +4328,23 @@ typedef NS_ENUM (NSUInteger, MXKRoomDataSourceError) {
self.secondaryRoomId = [self.mxSession virtualRoomOf:self.roomId];
}
#pragma mark - Use Only Latest Profiles
/**
Refreshes the avatars and display names if needed. This has no effect
if `roomScreenUseOnlyLatestProfiles` is disabled.
*/
- (void)refreshProfilesIfNeeded
{
if (RiotSettings.shared.roomScreenUseOnlyLatestProfiles)
{
@synchronized (bubbles) {
for (id<MXKRoomBubbleCellDataStoring> bubble in bubbles)
{
[bubble refreshProfileWithRoomDataSource:self];
}
}
}
}
@end