RoomVC: Show a "Resource Limit Exceeded" banner if it happens in a /sync response

#1937
This commit is contained in:
manuroe
2018-08-21 18:25:56 +02:00
parent 0b3692a65d
commit 760ad6a9f0
4 changed files with 139 additions and 3 deletions
+46 -3
View File
@@ -176,7 +176,10 @@
// Observe kAppDelegateNetworkStatusDidChangeNotification to handle network status change.
id kAppDelegateNetworkStatusDidChangeNotificationObserver;
// Observers to manage MXSession state (and sync errors)
id kMXSessionStateDidChangeObserver;
// Observers to manage ongoing conference call banner
id kMXCallStateDidChangeObserver;
id kMXCallManagerConferenceStartedObserver;
@@ -470,6 +473,7 @@
[self listenCallNotifications];
[self listenWidgetNotifications];
[self listenTombstoneEventNotifications];
[self listenMXSessionStateChangeNotifications];
if (self.showExpandedHeader)
{
@@ -519,6 +523,7 @@
[self removeCallNotificationsListeners];
[self removeWidgetNotificationsListeners];
[self removeTombstoneEventNotificationsListener];
[self removeMXSessionStateChangeNotificationsListener];
// Re-enable the read marker display, and disable its update.
self.roomDataSource.showReadMarker = YES;
@@ -1156,6 +1161,7 @@
[self removeCallNotificationsListeners];
[self removeWidgetNotificationsListeners];
[self removeTombstoneEventNotificationsListener];
[self removeMXSessionStateChangeNotificationsListener];
if (previewHeader || (self.expandedHeaderContainer.isHidden == NO))
{
@@ -3872,8 +3878,21 @@
}
Widget *jitsiWidget = [customizedRoomDataSource jitsiWidget];
if ([AppDelegate theDelegate].isOffline)
if ([self.roomDataSource.mxSession.syncError.errcode isEqualToString:kMXErrCodeStringResourceLimitExceeded])
{
[roomActivitiesView showResourceLimitExceededError:self.roomDataSource.mxSession.syncError.userInfo onAdminContactTapped:^(NSURL *adminContact) {
if ([[UIApplication sharedApplication] canOpenURL:adminContact])
{
[[UIApplication sharedApplication] openURL:adminContact];
}
else
{
NSLog(@"[RoomVC] refreshActivitiesViewDisplay: adminContact(%@) cannot be opened", adminContact);
}
}];
}
else if ([AppDelegate theDelegate].isOffline)
{
[roomActivitiesView displayNetworkErrorNotification:NSLocalizedStringFromTable(@"room_offline_notification", @"Vector", nil)];
}
@@ -4810,5 +4829,29 @@
}
}
#pragma mark MXSession state change
- (void)listenMXSessionStateChangeNotifications
{
kMXSessionStateDidChangeObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionStateDidChangeNotification object:self.roomDataSource.mxSession queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
if (self.roomDataSource.mxSession.state == MXSessionStateSyncError
|| self.roomDataSource.mxSession.state == MXSessionStateRunning)
{
[self refreshActivitiesViewDisplay];
[self refreshRoomInputToolbar];
}
}];
}
- (void)removeMXSessionStateChangeNotificationsListener
{
if (kMXSessionStateDidChangeObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:kMXSessionStateDidChangeObserver];
kMXSessionStateDidChangeObserver = nil;
}
}
@end