[Spaces] Show spaces in left panel #4509

- Display the none hierarchical list of spaces in the left panel
- Space switching when new space selected
- Refresh space list and recents data after sync
This commit is contained in:
Gil Eluard
2021-07-15 14:10:01 +02:00
parent 72eb0dfa56
commit 5937917c01
9 changed files with 158 additions and 33 deletions

View File

@@ -98,10 +98,16 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
// Set default data and view classes
[self registerCellDataClass:RecentCellData.class forCellIdentifier:kMXKRecentCellIdentifier];
[self registerSpaceServiceDidBuildGraphNotification];
}
return self;
}
- (void)dealloc
{
[self unregisterSpaceServiceDidBuildGraphNotification];
}
#pragma mark - Properties
@@ -166,6 +172,13 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
return state.unsentMessagesGroupDiscussionsCount;
}
- (void)setCurrentSpace:(MXSpace *)currentSpace
{
_currentSpace = currentSpace;
[self refreshRoomsSection:^{
[self.delegate dataSource:self didCellChange:nil];
}];
}
#pragma mark -
@@ -213,6 +226,23 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
return stickyHeader;
}
#pragma mark - Space Service notifications
- (void)registerSpaceServiceDidBuildGraphNotification
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(spaceServiceDidBuildGraphNotification:) name:MXSpaceService.didBuildSpaceGraph object:nil];
}
- (void)spaceServiceDidBuildGraphNotification:(NSNotification*)notification
{
[self forceRefresh];
}
- (void)unregisterSpaceServiceDidBuildGraphNotification
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:MXSpaceService.didBuildSpaceGraph object:nil];
}
#pragma mark - Key backup setup banner
- (void)registerKeyBackupStateDidChangeNotification
@@ -1204,7 +1234,10 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
for (NSUInteger index = 0; index < count; index++)
{
id<MXKRecentCellDataStoring> cell = [recentsDataSource cellDataAtIndex:index];
[cells addObject:cell];
if (self.currentSpace == nil || [self.currentSpace isRoomAChildWithRoomId:cell.roomSummary.roomId])
{
[cells addObject:cell];
}
}
MXWeakify(self);