vector-im/element-ios/issues/5009 - Implemented multi-room forwarding and added various tweaks following code review.

This commit is contained in:
Stefan Ceriu
2021-10-18 16:30:32 +03:00
parent 0621efbf21
commit ab30801310
25 changed files with 620 additions and 484 deletions
+32 -7
View File
@@ -19,27 +19,28 @@
@interface ShareDataSource ()
@property (nonatomic, assign, readonly) ShareDataSourceMode dataSourceMode;
@property (nonatomic, strong, readonly) MXFileStore *fileStore;
@property (nonatomic, strong, readonly) MXCredentials *credentials;
@property NSArray <MXKRecentCellData *> *recentCellDatas;
@property NSMutableArray <MXKRecentCellData *> *visibleRoomCellDatas;
@property (nonatomic, strong) NSMutableSet<NSString *> *internalSelectedRoomIdentifiers;
@end
@implementation ShareDataSource
- (instancetype)initWithMode:(ShareDataSourceMode)dataSourceMode
fileStore:(MXFileStore *)fileStore
credentials:(MXCredentials *)credentials
- (instancetype)initWithFileStore:(MXFileStore *)fileStore
credentials:(MXCredentials *)credentials
{
if (self = [super init])
{
_dataSourceMode = dataSourceMode;
_fileStore = fileStore;
_credentials = credentials;
_internalSelectedRoomIdentifiers = [NSMutableSet set];
[self loadCellData];
}
return self;
@@ -53,6 +54,25 @@
_visibleRoomCellDatas = nil;
}
- (NSSet<NSString *> *)selectedRoomIdentifiers
{
return self.internalSelectedRoomIdentifiers.copy;
}
- (void)selectRoomWithIdentifier:(NSString *)roomIdentifier animated:(BOOL)animated
{
[self.internalSelectedRoomIdentifiers addObject:roomIdentifier];
[self.shareDelegate shareDataSourceDidChangeSelectedRoomIdentifiers:self];
}
- (void)deselectRoomWithIdentifier:(NSString *)roomIdentifier animated:(BOOL)animated
{
[self.internalSelectedRoomIdentifiers removeObject:roomIdentifier];
[self.shareDelegate shareDataSourceDidChangeSelectedRoomIdentifiers:self];
}
#pragma mark - Private
- (void)loadCellData
@@ -66,7 +86,7 @@
for (MXRoomSummary *roomSummary in roomsSummaries)
{
if (!roomSummary.hiddenFromUser && ((self.dataSourceMode == DataSourceModeRooms) ^ roomSummary.isDirect))
if (!roomSummary.hiddenFromUser)
{
[roomSummary setMatrixSession:session];
@@ -137,6 +157,7 @@
{
self.visibleRoomCellDatas = nil;
}
[self.delegate dataSource:self didCellChange:nil];
}
@@ -160,7 +181,11 @@
{
RecentRoomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[RecentRoomTableViewCell defaultReuseIdentifier]];
[cell render:[self cellDataAtIndexPath:indexPath]];
MXKRecentCellData *data = [self cellDataAtIndexPath:indexPath];
[cell render:data];
[cell setCustomSelected:[self.selectedRoomIdentifiers containsObject:data.roomSummary.roomId] animated:NO];
return cell;
}