update Matrix Sessions handling.

This commit is contained in:
giomfo 2015-11-20 14:47:38 +01:00
parent ef28b58abb
commit 2419450531
3 changed files with 23 additions and 8 deletions

View file

@ -53,7 +53,7 @@
#pragma mark - Matrix Sessions handling
// Add a matrix session. This session is propagated to all view controllers handled by the tab bar controller.
// Add a matrix session.
- (void)addMatrixSession:(MXSession*)mxSession;
// Remove a matrix session.

View file

@ -638,12 +638,8 @@
// Check whether the concerned session is a new one
if (mxSession.state == MXSessionStateInitialised)
{
// Report this session to contact manager
[[MXKContactManager sharedManager] addMatrixSession:mxSession];
// Store this new session and update existing view controllers
// Store this new session
[self addMatrixSession:mxSession];
}
else if (mxSession.state == MXSessionStateStoreDataReady)
{
@ -660,7 +656,6 @@
}
else if (mxSession.state == MXSessionStateClosed)
{
[[MXKContactManager sharedManager] removeMatrixSession:mxSession];
[self removeMatrixSession:mxSession];
}
@ -773,6 +768,9 @@
{
if (mxSession)
{
// Report this session to contact manager
[[MXKContactManager sharedManager] addMatrixSession:mxSession];
// Update recents data source (The recents view controller will be updated by its data source)
if (!mxSessionArray.count)
{
@ -791,6 +789,8 @@
- (void)removeMatrixSession:(MXSession*)mxSession
{
[[MXKContactManager sharedManager] removeMatrixSession:mxSession];
// Update recents data source
[recentsViewController.dataSource removeMatrixSession:mxSession];

View file

@ -82,7 +82,6 @@
}];
// Add each matrix session, to update the view controller appearance according to mx sessions state
// FIXME GFO We should observe added/removed matrix sessions during view controller use.
NSArray *sessions = [AppDelegate theDelegate].mxSessions;
for (MXSession *mxSession in sessions)
{
@ -103,6 +102,22 @@
[super destroy];
}
- (void)onMatrixSessionStateDidChange:(NSNotification *)notif
{
MXSession *mxSession = notif.object;
// Check whether the concerned session is a new one which is not already associated with this view controller.
if (mxSession.state == MXSessionStateInitialised && [self.mxSessions indexOfObject:mxSession] != NSNotFound)
{
// Store this new session
[self addMatrixSession:mxSession];
}
else
{
[super onMatrixSessionStateDidChange:notif];
}
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];