mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-26 11:30:50 +02:00
[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:
@@ -19,6 +19,8 @@
|
||||
|
||||
#import "PublicRoomsDirectoryDataSource.h"
|
||||
|
||||
@class MXSpace;
|
||||
|
||||
/**
|
||||
List the different modes used to prepare the recents data source.
|
||||
Each mode corresponds to an application tab: Home, Favourites, People and Rooms.
|
||||
@@ -98,6 +100,8 @@ extern NSString *const kRecentsDataSourceTapOnDirectoryServerChange;
|
||||
*/
|
||||
@property (nonatomic) PublicRoomsDirectoryDataSource *publicRoomsDirectoryDataSource;
|
||||
|
||||
@property (nonatomic, strong) MXSpace *currentSpace;
|
||||
|
||||
/**
|
||||
Refresh the recents data source and notify its delegate.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user