mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Handle use only latest profile live refreshes
This commit is contained in:
parent
724eef1b83
commit
b2ff450a6f
3 changed files with 45 additions and 0 deletions
|
@ -107,6 +107,18 @@
|
|||
bubbleComponents = nil;
|
||||
}
|
||||
|
||||
- (void)refreshProfileWithRoomDataSource:(MXKRoomDataSource *)roomDataSource2
|
||||
{
|
||||
if (self.events.firstObject)
|
||||
{
|
||||
MXEvent* firstEvent = self.events.firstObject;
|
||||
senderDisplayName = [roomDataSource.eventFormatter senderDisplayNameForEvent:firstEvent
|
||||
withRoomState:roomDataSource2.roomState];
|
||||
senderAvatarUrl = [roomDataSource.eventFormatter senderAvatarUrlForEvent:firstEvent
|
||||
withRoomState:roomDataSource2.roomState];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSUInteger)updateEvent:(NSString *)eventId withEvent:(MXEvent *)event
|
||||
{
|
||||
NSUInteger count = 0;
|
||||
|
|
|
@ -231,6 +231,13 @@
|
|||
*/
|
||||
- (instancetype)initWithEvent:(MXEvent*)event andRoomState:(MXRoomState*)roomState andRoomDataSource:(MXKRoomDataSource*)roomDataSource;
|
||||
|
||||
/**
|
||||
Refreshes the avatar and display name if needed. Should be used only if `roomScreenUseOnlyLatestProfiles` is enabled.
|
||||
|
||||
@param roomDataSource the `MXKRoomDataSource` object that will use this instance.
|
||||
*/
|
||||
- (void)refreshProfileWithRoomDataSource:(MXKRoomDataSource*)roomDataSource;
|
||||
|
||||
/**
|
||||
Update the event because its sent state changed or it is has been redacted.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue