mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
update Matrix Sessions handling.
This commit is contained in:
parent
ef28b58abb
commit
2419450531
3 changed files with 23 additions and 8 deletions
|
@ -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.
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue