diff --git a/Riot/Modules/TabBar/MasterTabBarController.m b/Riot/Modules/TabBar/MasterTabBarController.m index 2ee405d94..60ff2441c 100644 --- a/Riot/Modules/TabBar/MasterTabBarController.m +++ b/Riot/Modules/TabBar/MasterTabBarController.m @@ -356,6 +356,12 @@ - (void)addMatrixSession:(MXSession *)mxSession { + if ([mxSessionArray containsObject:mxSession]) + { + MXLogDebug(@"MasterTabBarController already has %@ in mxSessionArray", mxSession) + return; + } + // Check whether the controller'€™s view is loaded into memory. if (self.homeViewController) { @@ -394,6 +400,12 @@ - (void)removeMatrixSession:(MXSession *)mxSession { + if (![mxSessionArray containsObject:mxSession]) + { + MXLogDebug(@"MasterTabBarController does not contain %@ in mxSessionArray", mxSession) + return; + } + [recentsDataSource removeMatrixSession:mxSession]; // Check whether there are others sessions diff --git a/Riot/Modules/TabBar/TabBarCoordinator.swift b/Riot/Modules/TabBar/TabBarCoordinator.swift index 823d7f505..83757eb73 100644 --- a/Riot/Modules/TabBar/TabBarCoordinator.swift +++ b/Riot/Modules/TabBar/TabBarCoordinator.swift @@ -291,18 +291,12 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType { // TODO: Remove Matrix session handling from the view controller private func addMatrixSessionToMasterTabBarController(_ matrixSession: MXSession) { - guard self.masterTabBarController.mxSessions.contains(matrixSession) == false else { - return - } MXLog.debug("[TabBarCoordinator] masterTabBarController.addMatrixSession") self.masterTabBarController.addMatrixSession(matrixSession) } // TODO: Remove Matrix session handling from the view controller private func removeMatrixSessionFromMasterTabBarController(_ matrixSession: MXSession) { - guard self.masterTabBarController.mxSessions.contains(matrixSession) else { - return - } MXLog.debug("[TabBarCoordinator] masterTabBarController.removeMatrixSession") self.masterTabBarController.removeMatrixSession(matrixSession) }