Show DM/room start header for every user

Signed-off-by: Andy Uhnak <andyuhnak@gmail.com>
This commit is contained in:
Andy Uhnak
2022-02-25 14:19:41 +00:00
parent 3027fe615e
commit 01ba286f76
3 changed files with 2 additions and 86 deletions
@@ -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