Merge pull request #253 from vector-im/vector_249

Fixed the UX issue in https://github.com/vector-im/vector-ios/issues/249
This commit is contained in:
manuroe 2016-04-22 18:08:59 +02:00
commit 57a660b515
2 changed files with 71 additions and 32 deletions

View file

@ -76,6 +76,7 @@
"room_creation_make_public_prompt_msg" = "Are you sure you want to make this chat public? Anyone can read your messages and join the chat.";
"room_creation_keep_private" = "Keep private";
"room_creation_make_private" = "Make private";
"room_creation_wait_for_creation" = "A room is already being created. Please wait.";
// Room recents
"room_recents_directory" = "DIRECTORY";

View file

@ -49,6 +49,9 @@
// The parameters to pass to the Authentification view controller.
NSDictionary *authViewControllerNextLinkParameters;
// Current alert (if any).
MXKAlert *currentAlert;
}
@end
@ -102,6 +105,12 @@
{
[super destroy];
if (currentAlert)
{
[currentAlert dismiss:NO];
currentAlert = nil;
}
if (authViewControllerObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:authViewControllerObserver];
@ -703,38 +712,67 @@
// Sanity check
if (self.mainSession)
{
createNewRoomImageView.userInteractionEnabled = NO;
[recentsViewController startActivityIndicator];
// Create an empty room.
roomCreationRequest = [self.mainSession createRoom:nil
visibility:kMXRoomVisibilityPrivate
roomAlias:nil
topic:nil
success:^(MXRoom *room) {
roomCreationRequest = nil;
[recentsViewController stopActivityIndicator];
createNewRoomImageView.userInteractionEnabled = YES;
[self selectRoomWithId:room.state.roomId andEventId:nil inMatrixSession:self.mainSession];
// Force the expanded header
self.currentRoomViewController.showExpandedHeader = YES;
} failure:^(NSError *error) {
roomCreationRequest = nil;
[recentsViewController stopActivityIndicator];
createNewRoomImageView.userInteractionEnabled = YES;
NSLog(@"[RoomCreation] Create new room failed");
// Alert user
[[AppDelegate theDelegate] showErrorAsAlert:error];
}];
// Create one room at time
if (!roomCreationRequest)
{
[recentsViewController startActivityIndicator];
// Create an empty room.
roomCreationRequest = [self.mainSession createRoom:nil
visibility:kMXRoomVisibilityPrivate
roomAlias:nil
topic:nil
success:^(MXRoom *room) {
roomCreationRequest = nil;
[recentsViewController stopActivityIndicator];
if (currentAlert)
{
[currentAlert dismiss:NO];
currentAlert = nil;
}
[self selectRoomWithId:room.state.roomId andEventId:nil inMatrixSession:self.mainSession];
// Force the expanded header
self.currentRoomViewController.showExpandedHeader = YES;
} failure:^(NSError *error) {
roomCreationRequest = nil;
[recentsViewController stopActivityIndicator];
if (currentAlert)
{
[currentAlert dismiss:NO];
currentAlert = nil;
}
NSLog(@"[RoomCreation] Create new room failed");
// Alert user
[[AppDelegate theDelegate] showErrorAsAlert:error];
}];
}
else
{
// Ask the user to wait
__weak __typeof(self) weakSelf = self;
currentAlert = [[MXKAlert alloc] initWithTitle:nil
message:NSLocalizedStringFromTable(@"room_creation_wait_for_creation", @"Vector", nil)
style:MXKAlertStyleAlert];
currentAlert.cancelButtonIndex = [currentAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"]
style:MXKAlertActionStyleCancel
handler:^(MXKAlert *alert) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
strongSelf->currentAlert = nil;
}];
[currentAlert showInViewController:self];
}
}
}