From 45037ccdaf693b770e796a2b7368279ea9212374 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Fri, 25 Feb 2022 14:19:41 +0000 Subject: [PATCH] Show DM/room start header for every user Signed-off-by: Andy Uhnak --- .../Room/CellData/RoomBubbleCellData.m | 2 +- .../Modules/Room/DataSources/RoomDataSource.m | 85 ------------------- changelog.d/5581.bugfix | 1 + 3 files changed, 2 insertions(+), 86 deletions(-) create mode 100644 changelog.d/5581.bugfix diff --git a/Riot/Modules/Room/CellData/RoomBubbleCellData.m b/Riot/Modules/Room/CellData/RoomBubbleCellData.m index 085bc137d..7bca5c723 100644 --- a/Riot/Modules/Room/CellData/RoomBubbleCellData.m +++ b/Riot/Modules/Room/CellData/RoomBubbleCellData.m @@ -107,7 +107,7 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat } else { - self.tag = RoomBubbleCellDataTagRoomCreateConfiguration; + self.tag = RoomBubbleCellDataTagRoomCreationIntro; } // Membership events can be collapsed together diff --git a/Riot/Modules/Room/DataSources/RoomDataSource.m b/Riot/Modules/Room/DataSources/RoomDataSource.m index f6b80f4e3..b24e57181 100644 --- a/Riot/Modules/Room/DataSources/RoomDataSource.m +++ b/Riot/Modules/Room/DataSources/RoomDataSource.m @@ -231,7 +231,6 @@ const CGFloat kTypingCellHeight = 24; } [self fetchEncryptionTrustedLevel]; - [self enableRoomCreationIntroCellDisplayIfNeeded]; } - (void)fetchEncryptionTrustedLevel @@ -240,11 +239,6 @@ const CGFloat kTypingCellHeight = 24; [self.roomDataSourceDelegate roomDataSourceDidUpdateEncryptionTrustLevel:self]; } -- (void)roomDidSet -{ - [self enableRoomCreationIntroCellDisplayIfNeeded]; -} - - (BOOL)shouldQueueEventForProcessing:(MXEvent *)event roomState:(MXRoomState *)roomState direction:(MXTimelineDirection)direction { if (self.threadId) @@ -302,8 +296,6 @@ const CGFloat kTypingCellHeight = 24; // Enable the containsLastMessage flag for the cell data which contains the last message. @synchronized(bubbles) { - [self insertRoomCreationIntroCellDataIfNeeded]; - // Reset first all cell data for (RoomBubbleCellData *cellData in bubbles) { @@ -1095,83 +1087,6 @@ const CGFloat kTypingCellHeight = 24; } } -#pragma mark - Room creation intro cell - -- (BOOL)canShowRoomCreationIntroCell -{ - NSString* userId = self.mxSession.myUser.userId; - - if (!userId || !self.isLive || self.isPeeking) - { - return NO; - } - - // Room creation cell is only shown for the creator - return [self.room.summary.creatorUserId isEqualToString:userId]; -} - -- (void)enableRoomCreationIntroCellDisplayIfNeeded -{ - self.showRoomCreationCell = [self canShowRoomCreationIntroCell]; -} - -// Insert the room creation intro cell at the begining -- (void)insertRoomCreationIntroCellDataIfNeeded -{ - @synchronized(bubbles) - { - NSUInteger existingRoomCreationCellDataIndex = [self roomBubbleDataIndexWithTag:RoomBubbleCellDataTagRoomCreationIntro]; - - if (existingRoomCreationCellDataIndex != NSNotFound) - { - [bubbles removeObjectAtIndex:existingRoomCreationCellDataIndex]; - } - - if (self.showRoomCreationCell) - { - NSUInteger roomCreationConfigCellDataIndex = [self roomBubbleDataIndexWithTag:RoomBubbleCellDataTagRoomCreateConfiguration]; - - // Only add room creation intro cell if `bubbles` array contains the room creation event - if (roomCreationConfigCellDataIndex != NSNotFound) - { - if (!self.roomCreationCellData) - { - MXEvent *event = [MXEvent new]; - MXRoomState *roomState = [MXRoomState new]; - RoomBubbleCellData *roomBubbleCellData = [[RoomBubbleCellData alloc] initWithEvent:event andRoomState:roomState andRoomDataSource:self]; - roomBubbleCellData.tag = RoomBubbleCellDataTagRoomCreationIntro; - - self.roomCreationCellData = roomBubbleCellData; - } - - [bubbles insertObject:self.roomCreationCellData atIndex:0]; - } - } - else - { - self.roomCreationCellData = nil; - } - } -} - -- (NSUInteger)roomBubbleDataIndexWithTag:(RoomBubbleCellDataTag)tag -{ - @synchronized(bubbles) - { - return [bubbles indexOfObjectPassingTest:^BOOL(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj isKindOfClass:RoomBubbleCellData.class]) - { - RoomBubbleCellData *roomBubbleCellData = (RoomBubbleCellData*)obj; - if (roomBubbleCellData.tag == tag) - { - return YES; - } - } - return NO; - }]; - } -} - #pragma mark - URLPreviewViewDelegate - (void)didOpenURLFromPreviewView:(URLPreviewView *)previewView for:(NSString *)eventID in:(NSString *)roomID diff --git a/changelog.d/5581.bugfix b/changelog.d/5581.bugfix new file mode 100644 index 000000000..7ab69c03c --- /dev/null +++ b/changelog.d/5581.bugfix @@ -0,0 +1 @@ +Timeline: Show start of conversation header for every user and only at the actual start of the timeline