Merge branch 'develop' into gil/SP1_space_creation

# Conflicts:
#	Riot/Modules/Room/Members/RoomParticipantsViewController.m
#	Riot/Modules/Room/RoomViewController.m
#	Riot/Modules/Room/Settings/RoomSettingsViewController.h
#	Riot/Modules/Spaces/SpaceMembers/MemberList/SpaceMemberListViewController.swift
This commit is contained in:
Gil Eluard
2022-03-08 11:23:55 +01:00
82 changed files with 515 additions and 344 deletions
@@ -90,6 +90,10 @@
*/
@property (nonatomic) MXIdentityService *identityService;
@property (nonatomic) AnalyticsScreenTracker *screenTracker;
@property (nonatomic) BOOL isViewVisible;
@end
@implementation MXKAuthenticationViewController
@@ -187,6 +191,9 @@
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onTextFieldChange:) name:UITextFieldTextDidChangeNotification object:nil];
self.isViewVisible = YES;
[self.screenTracker trackScreen];
}
- (void)viewWillDisappear:(BOOL)animated
@@ -206,6 +213,13 @@
[[NSNotificationCenter defaultCenter] removeObserver:self name:UITextFieldTextDidChangeNotification object:nil];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
self.isViewVisible = NO;
}
#pragma mark - Override MXKViewController
- (void)onKeyboardShowAnimationComplete
@@ -312,6 +326,8 @@
// Update supported authentication flow and associated information (defined in authentication session)
[self refreshAuthenticationSession];
self.screenTracker = [[AnalyticsScreenTracker alloc] initWithScreen:AnalyticsScreenLogin];
}
else if (authType == MXKAuthenticationTypeRegister)
{
@@ -324,6 +340,8 @@
// Update supported authentication flow and associated information (defined in authentication session)
[self refreshAuthenticationSession];
self.screenTracker = [[AnalyticsScreenTracker alloc] initWithScreen:AnalyticsScreenRegister];
}
else if (authType == MXKAuthenticationTypeForgotPassword)
{
@@ -344,8 +362,15 @@
[_authSwitchButton setTitle:[VectorL10n back] forState:UIControlStateNormal];
[_authSwitchButton setTitle:[VectorL10n back] forState:UIControlStateHighlighted];
self.screenTracker = [[AnalyticsScreenTracker alloc] initWithScreen:AnalyticsScreenForgotPassword];
}
if (self.isViewVisible)
{
[self.screenTracker trackScreen];
}
[self checkIdentityServer];
}
@@ -26,6 +26,8 @@
#import "MXKTools.h"
#import "GeneratedInterface-Swift.h"
@implementation MXKRoomBubbleCellData
@synthesize senderId, targetId, roomId, senderDisplayName, senderAvatarUrl, senderAvatarPlaceholder, targetDisplayName, targetAvatarUrl, targetAvatarPlaceholder, isEncryptedRoom, isPaginationFirstBubble, shouldHideSenderInformation, date, isIncoming, isAttachmentWithThumbnail, isAttachmentWithIcon, attachment, senderFlair;
@synthesize textMessage, attributedTextMessage, attributedTextMessageWithoutPositioningSpace;
@@ -35,12 +37,12 @@
#pragma mark - MXKRoomBubbleCellDataStoring
- (instancetype)initWithEvent:(MXEvent *)event andRoomState:(MXRoomState *)roomState andRoomDataSource:(MXKRoomDataSource *)roomDataSource2
- (instancetype)initWithEvent:(MXEvent *)event andRoomState:(MXRoomState *)roomState andRoomDataSource:(MXKRoomDataSource *)roomDataSource
{
self = [self init];
if (self)
{
roomDataSource = roomDataSource2;
self->roomDataSource = roomDataSource;
// Initialize read receipts
self.readReceipts = [NSMutableDictionary dictionary];
@@ -55,12 +57,17 @@
senderId = event.sender;
targetId = [event.type isEqualToString:kMXEventTypeStringRoomMember] ? event.stateKey : nil;
roomId = roomDataSource.roomId;
senderDisplayName = [roomDataSource.eventFormatter senderDisplayNameForEvent:event withRoomState:roomState];
senderAvatarUrl = [roomDataSource.eventFormatter senderAvatarUrlForEvent:event withRoomState:roomState];
// If `roomScreenUseOnlyLatestUserAvatarAndName`is enabled, the avatar and name are
// displayed from the latest room state perspective rather than the historical.
MXRoomState *latestRoomState = roomDataSource.roomState;
MXRoomState *displayRoomState = RiotSettings.shared.roomScreenUseOnlyLatestUserAvatarAndName ? latestRoomState : roomState;
[self setRoomState:displayRoomState];
senderAvatarPlaceholder = nil;
targetDisplayName = [roomDataSource.eventFormatter targetDisplayNameForEvent:event withRoomState:roomState];
targetAvatarUrl = [roomDataSource.eventFormatter targetAvatarUrlForEvent:event withRoomState:roomState];
targetAvatarPlaceholder = nil;
// Encryption status should always rely on the `MXRoomState`
// from the event rather than the latest.
isEncryptedRoom = roomState.isEncrypted;
isIncoming = ([event.sender isEqualToString:roomDataSource.mxSession.myUser.userId] == NO);
@@ -103,6 +110,25 @@
bubbleComponents = nil;
}
- (void)setRoomState:(MXRoomState *)roomState;
{
MXEvent* firstEvent = self.events.firstObject;
if (firstEvent == nil || roomState == nil)
{
return;
}
senderDisplayName = [roomDataSource.eventFormatter senderDisplayNameForEvent:firstEvent
withRoomState:roomState];
senderAvatarUrl = [roomDataSource.eventFormatter senderAvatarUrlForEvent:firstEvent
withRoomState:roomState];
targetDisplayName = [roomDataSource.eventFormatter targetDisplayNameForEvent:firstEvent
withRoomState:roomState];
targetAvatarUrl = [roomDataSource.eventFormatter targetAvatarUrlForEvent:firstEvent
withRoomState:roomState];
}
- (NSUInteger)updateEvent:(NSString *)eventId withEvent:(MXEvent *)event
{
NSUInteger count = 0;
@@ -231,6 +231,15 @@
*/
- (instancetype)initWithEvent:(MXEvent*)event andRoomState:(MXRoomState*)roomState andRoomDataSource:(MXKRoomDataSource*)roomDataSource;
/**
Sets the `MXRoomState` for a buble cell. This allows to adapt the display
of a cell with a different room state than its historical. This won't update critical
flag/status, such as `isEncryptedRoom`.
@param roomState the `MXRoomState` to use for this cell.
*/
- (void)setRoomState:(MXRoomState *)roomState;
/**
Update the event because its sent state changed or it is has been redacted.
@@ -16,15 +16,17 @@
#import "MXKRoomBubbleCellDataWithAppendingMode.h"
#import "GeneratedInterface-Swift.h"
static NSAttributedString *messageSeparator = nil;
@implementation MXKRoomBubbleCellDataWithAppendingMode
#pragma mark - MXKRoomBubbleCellDataStoring
- (instancetype)initWithEvent:(MXEvent *)event andRoomState:(MXRoomState *)roomState andRoomDataSource:(MXKRoomDataSource *)roomDataSource2
- (instancetype)initWithEvent:(MXEvent *)event andRoomState:(MXRoomState *)roomState andRoomDataSource:(MXKRoomDataSource *)roomDataSource
{
self = [super initWithEvent:event andRoomState:roomState andRoomDataSource:roomDataSource2];
self = [super initWithEvent:event andRoomState:roomState andRoomDataSource:roomDataSource];
if (self)
{
// Set default settings
@@ -46,8 +48,12 @@ static NSAttributedString *messageSeparator = nil;
}
// Check sender information
NSString *eventSenderName = [roomDataSource.eventFormatter senderDisplayNameForEvent:event withRoomState:roomState];
NSString *eventSenderAvatar = [roomDataSource.eventFormatter senderAvatarUrlForEvent:event withRoomState:roomState];
// If `roomScreenUseOnlyLatestUserAvatarAndName`is enabled, the avatar and name are
// displayed from the latest room state perspective rather than the historical.
MXRoomState *latestRoomState = roomDataSource.roomState;
MXRoomState *displayRoomState = RiotSettings.shared.roomScreenUseOnlyLatestUserAvatarAndName ? latestRoomState : roomState;
NSString *eventSenderName = [roomDataSource.eventFormatter senderDisplayNameForEvent:event withRoomState:displayRoomState];
NSString *eventSenderAvatar = [roomDataSource.eventFormatter senderAvatarUrlForEvent:event withRoomState:displayRoomState];
if ((self.senderDisplayName || eventSenderName) &&
([self.senderDisplayName isEqualToString:eventSenderName] == NO))
{
@@ -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 (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 `roomScreenUseOnlyLatestUserAvatarAndName` is disabled.
*/
- (void)refreshProfilesIfNeeded
{
if (RiotSettings.shared.roomScreenUseOnlyLatestUserAvatarAndName)
{
@synchronized (bubbles) {
for (id<MXKRoomBubbleCellDataStoring> bubble in bubbles)
{
[bubble setRoomState:self.roomState];
}
}
}
}
@end