mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 09:02:44 +02:00
[RoomViewController] Handle obsolete room (m.room.tombstone event type) and display replacement room in activities view
This commit is contained in:
@@ -204,6 +204,9 @@
|
||||
|
||||
// Tell whether the input text field is in send reply mode. If true typed message will be sent to highlighted event.
|
||||
BOOL isInReplyMode;
|
||||
|
||||
// Listener for `m.room.tombstone` event type
|
||||
id tombstoneEventNotificationsListener;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -367,13 +370,7 @@
|
||||
// Replace the default input toolbar view.
|
||||
// Note: this operation will force the layout of subviews. That is why cell view classes must be registered before.
|
||||
[self setRoomInputToolbarViewClass];
|
||||
|
||||
// Update the inputToolBar height.
|
||||
CGFloat height = [self inputToolbarHeight];
|
||||
// Disable animation during the update
|
||||
[UIView setAnimationsEnabled:NO];
|
||||
[self roomInputToolbarView:self.inputToolbarView heightDidChanged:height completion:nil];
|
||||
[UIView setAnimationsEnabled:YES];
|
||||
[self updateInputToolBarViewHeight];
|
||||
|
||||
// set extra area
|
||||
[self setRoomActivitiesViewClass:RoomActivitiesView.class];
|
||||
@@ -470,6 +467,7 @@
|
||||
[self listenTypingNotifications];
|
||||
[self listenCallNotifications];
|
||||
[self listenWidgetNotifications];
|
||||
[self listenTombstoneEventNotifications];
|
||||
|
||||
if (self.showExpandedHeader)
|
||||
{
|
||||
@@ -518,6 +516,7 @@
|
||||
|
||||
[self removeCallNotificationsListeners];
|
||||
[self removeWidgetNotificationsListeners];
|
||||
[self removeTombstoneEventNotificationsListener];
|
||||
|
||||
// Re-enable the read marker display, and disable its update.
|
||||
self.roomDataSource.showReadMarker = YES;
|
||||
@@ -892,13 +891,7 @@
|
||||
if (!self.inputToolbarView)
|
||||
{
|
||||
[self setRoomInputToolbarViewClass];
|
||||
|
||||
// Update the inputToolBar height.
|
||||
CGFloat height = [self inputToolbarHeight];
|
||||
// Disable animation during the update
|
||||
[UIView setAnimationsEnabled:NO];
|
||||
[self roomInputToolbarView:self.inputToolbarView heightDidChanged:height completion:nil];
|
||||
[UIView setAnimationsEnabled:YES];
|
||||
[self updateInputToolBarViewHeight];
|
||||
|
||||
[self refreshRoomInputToolbar];
|
||||
|
||||
@@ -939,9 +932,15 @@
|
||||
{
|
||||
MXRoomPowerLevels *powerLevels = self.roomDataSource.room.state.powerLevels;
|
||||
NSInteger userPowerLevel = [powerLevels powerLevelOfUserWithUserID:self.mainSession.myUser.userId];
|
||||
|
||||
|
||||
BOOL canSend = (userPowerLevel >= [powerLevels minimumPowerLevelForSendingEventAsMessage:kMXEventTypeStringRoomMessage]);
|
||||
if (!canSend)
|
||||
BOOL isRoomObsolete = self.roomDataSource.room.state.isObsolete;
|
||||
|
||||
if (isRoomObsolete)
|
||||
{
|
||||
roomInputToolbarViewClass = nil;
|
||||
}
|
||||
else if (!canSend)
|
||||
{
|
||||
roomInputToolbarViewClass = DisabledRoomInputToolbarView.class;
|
||||
}
|
||||
@@ -1150,6 +1149,7 @@
|
||||
|
||||
[self removeCallNotificationsListeners];
|
||||
[self removeWidgetNotificationsListeners];
|
||||
[self removeTombstoneEventNotificationsListener];
|
||||
|
||||
if (previewHeader || (self.expandedHeaderContainer.isHidden == NO))
|
||||
{
|
||||
@@ -1441,6 +1441,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateInputToolBarViewHeight
|
||||
{
|
||||
// Update the inputToolBar height.
|
||||
CGFloat height = [self inputToolbarHeight];
|
||||
// Disable animation during the update
|
||||
[UIView setAnimationsEnabled:NO];
|
||||
[self roomInputToolbarView:self.inputToolbarView heightDidChanged:height completion:nil];
|
||||
[UIView setAnimationsEnabled:YES];
|
||||
}
|
||||
|
||||
#pragma mark - Hide/Show expanded header
|
||||
|
||||
- (void)showExpandedHeader:(BOOL)isVisible
|
||||
@@ -3531,13 +3541,7 @@
|
||||
{
|
||||
// Enable back the text input
|
||||
[self setRoomInputToolbarViewClass:RoomInputToolbarView.class];
|
||||
|
||||
// Update the inputToolBar height.
|
||||
CGFloat height = [self inputToolbarHeight];
|
||||
// Disable animation during the update
|
||||
[UIView setAnimationsEnabled:NO];
|
||||
[self roomInputToolbarView:self.inputToolbarView heightDidChanged:height completion:nil];
|
||||
[UIView setAnimationsEnabled:YES];
|
||||
[self updateInputToolBarViewHeight];
|
||||
|
||||
// And the extra area
|
||||
[self setRoomActivitiesViewClass:RoomActivitiesView.class];
|
||||
@@ -3828,6 +3832,15 @@
|
||||
{
|
||||
[roomActivitiesView displayNetworkErrorNotification:NSLocalizedStringFromTable(@"room_offline_notification", @"Vector", nil)];
|
||||
}
|
||||
else if (customizedRoomDataSource.room.state.isObsolete)
|
||||
{
|
||||
NSString *replacementRoomId = customizedRoomDataSource.room.state.tombStoneContent.replacementRoomId;
|
||||
NSString *roomLinkFragment = [NSString stringWithFormat:@"/room/%@", [replacementRoomId stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
[roomActivitiesView displayRoomReplacementWithRoomLinkTappedHandler:^{
|
||||
[[AppDelegate theDelegate] handleUniversalLinkFragment:roomLinkFragment];
|
||||
}];
|
||||
}
|
||||
else if (customizedRoomDataSource.room.state.isOngoingConferenceCall)
|
||||
{
|
||||
// Show the "Ongoing conference call" banner only if the user is not in the conference
|
||||
@@ -4711,5 +4724,42 @@
|
||||
[self presentViewController:currentAlert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
#pragma mark Tombstone event
|
||||
|
||||
- (void)listenTombstoneEventNotifications
|
||||
{
|
||||
// Room is already obsolete do not listen to tombstone event
|
||||
if (self.roomDataSource.room.state.isObsolete)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MXWeakify(self);
|
||||
|
||||
tombstoneEventNotificationsListener = [self.roomDataSource.room.liveTimeline listenToEventsOfTypes:@[kMXEventTypeStringRoomTombStone] onEvent:^(MXEvent *event, MXTimelineDirection direction, MXRoomState *roomState) {
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
// Update activitiesView with room replacement information
|
||||
[self refreshActivitiesViewDisplay];
|
||||
// Hide inputToolbarView
|
||||
[self setRoomInputToolbarViewClass];
|
||||
[self updateInputToolBarViewHeight];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)removeTombstoneEventNotificationsListener
|
||||
{
|
||||
if (self.roomDataSource)
|
||||
{
|
||||
// Remove the previous live listener
|
||||
if (tombstoneEventNotificationsListener)
|
||||
{
|
||||
[self.roomDataSource.room.liveTimeline removeListener:tombstoneEventNotificationsListener];
|
||||
tombstoneEventNotificationsListener = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user