Merge pull request #1840 from vector-im/riot_1839

Improve Error Notifications (based on kMXKErrorNotification)
This commit is contained in:
giomfo
2018-04-17 13:37:58 +02:00
committed by GitHub
4 changed files with 78 additions and 41 deletions
+5 -1
View File
@@ -1,6 +1,7 @@
/*
Copyright 2015 OpenMarket Ltd
Copyright 2017 Vector Creations Ltd
Copyright 2018 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -57,9 +58,12 @@
} failure:^(NSError *error) {
NSLog(@"[MXRoom+Riot] Failed to update the tag %@ of room (%@)", tag, self.state.roomId);
NSString *userId = self.mxSession.myUser.userId;
// Notify user
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error];
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification
object:error
userInfo:userId ? @{kMXKErrorUserIdKey: userId} : nil];
if (completion)
{
+50 -26
View File
@@ -1,6 +1,7 @@
/*
Copyright 2015 OpenMarket Ltd
Copyright 2017 Vector Creations Ltd
Copyright 2018 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -981,6 +982,7 @@
self->currentAlert = nil;
// Check whether the user didn't leave the room yet
// TODO: Handle multi-account
MXRoom *room = [self.mainSession roomWithRoomId:currentRoomId];
if (room)
{
@@ -996,22 +998,32 @@
[room leave:^{
[self stopActivityIndicator];
// Force table refresh
[self cancelEditionMode:YES];
if (weakSelf)
{
typeof(self) self = weakSelf;
[self stopActivityIndicator];
// Force table refresh
[self cancelEditionMode:YES];
}
} failure:^(NSError *error) {
NSLog(@"[RecentsViewController] Failed to leave room (%@)", room.state.roomId);
NSLog(@"[RecentsViewController] Failed to leave room");
if (weakSelf)
{
typeof(self) self = weakSelf;
// Notify the end user
NSString *userId = room.mxSession.myUser.userId;
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification
object:error
userInfo:userId ? @{kMXKErrorUserIdKey: userId} : nil];
[self stopActivityIndicator];
// Leave editing mode
[self cancelEditionMode:isRefreshPending];
}
// Notify MatrixKit user
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error];
[self stopActivityIndicator];
// Leave editing mode
[self cancelEditionMode:isRefreshPending];
}];
}
else
@@ -1059,7 +1071,10 @@
{
if (editedRoomId)
{
__weak typeof(self) weakSelf = self;
// Check whether the user didn't leave the room
// TODO: handle multi-account
MXRoom *room = [self.mainSession roomWithRoomId:editedRoomId];
if (room)
{
@@ -1067,23 +1082,32 @@
[room setIsDirect:isDirect withUserId:nil success:^{
[self stopActivityIndicator];
// Leave editing mode
[self cancelEditionMode:isRefreshPending];
if (weakSelf)
{
typeof(self) self = weakSelf;
[self stopActivityIndicator];
// Leave editing mode
[self cancelEditionMode:isRefreshPending];
}
} failure:^(NSError *error) {
[self stopActivityIndicator];
NSLog(@"[RecentsViewController] Failed to update direct tag of the room (%@)", editedRoomId);
// Notify MatrixKit user
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error];
// Leave editing mode
[self cancelEditionMode:isRefreshPending];
if (weakSelf)
{
typeof(self) self = weakSelf;
[self stopActivityIndicator];
NSLog(@"[RecentsViewController] Failed to update direct tag of the room (%@)", editedRoomId);
// Notify the end user
NSString *userId = self.mainSession.myUser.userId; // TODO: handle multi-account
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification
object:error
userInfo:userId ? @{kMXKErrorUserIdKey: userId} : nil];
// Leave editing mode
[self cancelEditionMode:isRefreshPending];
}
}];
}
@@ -1,6 +1,7 @@
/*
Copyright 2016 OpenMarket Ltd
Copyright 2017 Vector Creations Ltd
Copyright 2018 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -415,9 +416,7 @@
{
// Restore the status bar
typeof(self) self = weakSelf;
self->devicesArray = usersDevicesInfoMap.map[userId].allValues;
// Reload the full table to take into account a potential change on a device status.
[super updateMemberInfo];
}
@@ -425,9 +424,15 @@
} failure:^(NSError *error) {
NSLog(@"[RoomMemberDetailsVC] Crypto failed to download device info for user: %@", userId);
// Notify MatrixKit user
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error];
if (weakSelf)
{
// Restore the status bar
typeof(self) self = weakSelf;
// Notify the end user
NSString *myUserId = self.mainSession.myUser.userId;
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error userInfo:myUserId ? @{kMXKErrorUserIdKey: myUserId} : nil];
}
}];
}
+13 -9
View File
@@ -1,6 +1,7 @@
/*
Copyright 2015 OpenMarket Ltd
Copyright 2017 Vector Creations Ltd
Copyright 2018 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -707,7 +708,8 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
[self stopActivityIndicator];
// Notify user
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error];
NSString *myUserId = self.mainSession.myUser.userId; // TODO: Hanlde multi-account
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error userInfo:myUserId ? @{kMXKErrorUserIdKey: myUserId} : nil];
}
}
}
@@ -817,8 +819,8 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
{
[self stopActivityIndicator];
// Notify user
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error];
NSString *myUserId = self.mainSession.myUser.userId; // TODO: Hanlde multi-account
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error userInfo:myUserId ? @{kMXKErrorUserIdKey: myUserId} : nil];
}
}
@@ -2446,8 +2448,8 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
NSLog(@"[SettingsViewController] Unignore %@ failed", ignoredUserId);
// Notify user
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error];
NSString *myUserId = session.myUser.userId;
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error userInfo:myUserId ? @{kMXKErrorUserIdKey: myUserId} : nil];
}];
}
@@ -2724,8 +2726,8 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
[self stopActivityIndicator];
// Notify user
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error];
NSString *myUserId = self.mainSession.myUser.userId; // TODO: Hanlde multi-account
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error userInfo:myUserId ? @{kMXKErrorUserIdKey: myUserId} : nil];
}
}];
}
@@ -3413,7 +3415,8 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
}
// Notify user
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error];
NSString *myUserId = session.myUser.userId; // TODO: Hanlde multi-account
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error userInfo:myUserId ? @{kMXKErrorUserIdKey: myUserId} : nil];
}];
}
@@ -3515,7 +3518,8 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
}
// Notify user
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error];
NSString *myUserId = session.myUser.userId;
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error userInfo:myUserId ? @{kMXKErrorUserIdKey: myUserId} : nil];
}];
}