Merge pull request #2569 from vector-im/riot_2486

Room upgrade: Autojoin the upgraded room when the user taps on the tombstone banner
This commit is contained in:
manuroe
2019-07-10 15:58:08 +02:00
committed by GitHub
2 changed files with 37 additions and 11 deletions
+1
View File
@@ -4,6 +4,7 @@ Changes in 0.8.7 (2019-xx-xx)
Improvements:
* RoomVC: When replying, use a "Reply" button instead of "Send".
* RoomVC: New message actions (#2394).
* Room upgrade: Autojoin the upgraded room when the user taps on the tombstone banner (#2486).
* Room upgrade: Use the `server_name` parameter when joining the new room (#2550).
* Join Room: Support via parameters to better handle federation (#2547).
* Reactions: Display existing reactions below the message (#2396).
+36 -11
View File
@@ -4048,18 +4048,43 @@
}
else if (customizedRoomDataSource.roomState.isObsolete)
{
// Try to join via the server that sent the event
MXEvent *stoneTombEvent = [customizedRoomDataSource.roomState stateEventsWithType:kMXEventTypeStringRoomTombStone].lastObject;
NSString *viaSenderServer = [MXTools serverNameInMatrixIdentifier:stoneTombEvent.sender];
NSString *replacementRoomId = customizedRoomDataSource.roomState.tombStoneContent.replacementRoomId;
NSString *roomLinkFragment = [NSString stringWithFormat:@"/room/%@?via=%@",
[MXTools encodeURIComponent:replacementRoomId],
viaSenderServer
];
MXWeakify(self);
[roomActivitiesView displayRoomReplacementWithRoomLinkTappedHandler:^{
[[AppDelegate theDelegate] handleUniversalLinkFragment:roomLinkFragment];
MXStrongifyAndReturnIfNil(self);
MXEvent *stoneTombEvent = [self->customizedRoomDataSource.roomState stateEventsWithType:kMXEventTypeStringRoomTombStone].lastObject;
NSString *replacementRoomId = self->customizedRoomDataSource.roomState.tombStoneContent.replacementRoomId;
if ([self.roomDataSource.mxSession roomWithRoomId:replacementRoomId])
{
// Open the room if it is already joined
[[AppDelegate theDelegate] showRoom:replacementRoomId andEventId:nil withMatrixSession:self.roomDataSource.mxSession];
}
else
{
// Else auto join it via the server that sent the event
NSLog(@"[RoomVC] Auto join an upgraded room: %@ -> %@. Sender: %@", self->customizedRoomDataSource.roomState.roomId,
replacementRoomId, stoneTombEvent.sender);
NSString *viaSenderServer = [MXTools serverNameInMatrixIdentifier:stoneTombEvent.sender];
if (viaSenderServer)
{
[self startActivityIndicator];
[self.roomDataSource.mxSession joinRoom:replacementRoomId viaServers:@[viaSenderServer] success:^(MXRoom *room) {
[self stopActivityIndicator];
[[AppDelegate theDelegate] showRoom:replacementRoomId andEventId:nil withMatrixSession:self.roomDataSource.mxSession];
} failure:^(NSError *error) {
[self stopActivityIndicator];
NSLog(@"[RoomVC] Failed to join an upgraded room. Error: %@",
error);
[[AppDelegate theDelegate] showErrorAsAlert:error];
}];
}
}
}];
}
else if (customizedRoomDataSource.roomState.isOngoingConferenceCall)