Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

BugFix: Handle the error on joining a room where everyone has left #99

Merged
merged 1 commit into from
Apr 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@

// Room
"room_please_select" = "Please select a room";
"room_error_join_failed" = "Failed to join room (%@)";
"room_error_join_failed_title" = "Failed to join room";
"room_error_join_failed_empty_room" = "It is not currently possible to re-join an empty room.";
"room_error_name_edition_not_authorized" = "You are not authorized to edit this room name";
"room_error_topic_edition_not_authorized" = "You are not authorized to edit this room topic";
"room_left" = "You left the room";
Expand Down
22 changes: 18 additions & 4 deletions MatrixKit/Controllers/MXKRoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,15 @@ - (void)joinRoom:(void(^)(BOOL succeed))completion

// Show the error to the end user
__weak typeof(self) weakSelf = self;
currentAlert = [[MXKAlert alloc] initWithTitle:[NSBundle mxk_localizedStringForKey:@"error"]
message:[NSString stringWithFormat:[NSBundle mxk_localizedStringForKey:@"room_error_join_failed"], roomDataSource.room.state.displayname]
NSString *msg = [error.userInfo valueForKey:NSLocalizedDescriptionKey];
if ([msg isEqualToString:@"No known servers"])
{
// minging kludge until https://matrix.org/jira/browse/SYN-678 is fixed
// 'Error when trying to join an empty room should be more explicit'
msg = [NSBundle mxk_localizedStringForKey:@"room_error_join_failed_empty_room"];
}
currentAlert = [[MXKAlert alloc] initWithTitle:[NSBundle mxk_localizedStringForKey:@"room_error_join_failed_title"]
message:msg
style:MXKAlertStyleAlert];
currentAlert.cancelButtonIndex = [currentAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
{
Expand Down Expand Up @@ -875,9 +882,16 @@ - (void)joinRoomWithRoomId:(NSString*)roomIdOrAlias andSignUrl:(NSString*)signUr
[self stopActivityIndicator];

// Show the error to the end user
NSString *msg = [error.userInfo valueForKey:NSLocalizedDescriptionKey];
if ([msg isEqualToString:@"No known servers"])
{
// minging kludge until https://matrix.org/jira/browse/SYN-678 is fixed
// 'Error when trying to join an empty room should be more explicit'
msg = [NSBundle mxk_localizedStringForKey:@"room_error_join_failed_empty_room"];
}
__weak typeof(self) weakSelf = self;
currentAlert = [[MXKAlert alloc] initWithTitle:[NSBundle mxk_localizedStringForKey:@"error"]
message:[NSString stringWithFormat:[NSBundle mxk_localizedStringForKey:@"room_error_join_failed"], roomIdOrAlias]
currentAlert = [[MXKAlert alloc] initWithTitle:[NSBundle mxk_localizedStringForKey:@"room_error_join_failed_title"]
message:msg
style:MXKAlertStyleAlert];
currentAlert.cancelButtonIndex = [currentAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert)
{
Expand Down