Merge pull request #5703 from vector-im/andy/5581_scrollback

Show DM/room start header for every user
This commit is contained in:
Anderas 2022-02-25 15:18:36 +00:00 committed by GitHub
commit aba47a82a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 86 deletions

View file

@ -107,7 +107,7 @@ NSString *const URLPreviewDidUpdateNotification = @"URLPreviewDidUpdateNotificat
}
else
{
self.tag = RoomBubbleCellDataTagRoomCreateConfiguration;
self.tag = RoomBubbleCellDataTagRoomCreationIntro;
}
// Membership events can be collapsed together

View file

@ -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<MXKRoomBubbleCellDataStoring> _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

1
changelog.d/5581.bugfix Normal file
View file

@ -0,0 +1 @@
Timeline: Show start of conversation header for every user and only at the actual start of the timeline