diff --git a/MatrixKit/Models/RoomList/MXKRecentsDataSource.h b/MatrixKit/Models/RoomList/MXKRecentsDataSource.h index 5c362568..150aac2a 100644 --- a/MatrixKit/Models/RoomList/MXKRecentsDataSource.h +++ b/MatrixKit/Models/RoomList/MXKRecentsDataSource.h @@ -57,6 +57,8 @@ */ @property (nonatomic, readonly) NSArray* searchPatternsList; +@property (nonatomic, strong) MXSpace *currentSpace; + #pragma mark - Configuration /** diff --git a/MatrixKit/Models/RoomList/MXKRecentsDataSource.m b/MatrixKit/Models/RoomList/MXKRecentsDataSource.m index 006c9d30..ab4bb748 100644 --- a/MatrixKit/Models/RoomList/MXKRecentsDataSource.m +++ b/MatrixKit/Models/RoomList/MXKRecentsDataSource.m @@ -126,6 +126,15 @@ - (void)removeMatrixSession:(MXSession*)matrixSession } } +- (void)setCurrentSpace:(MXSpace *)currentSpace +{ + _currentSpace = currentSpace; + + for (MXKSessionRecentsDataSource *recentsDataSource in recentsDataSourceArray) { + recentsDataSource.currentSpace = currentSpace; + } +} + #pragma mark - MXKDataSource overridden - (MXSession*)mxSession diff --git a/MatrixKit/Models/RoomList/MXKSessionRecentsDataSource.h b/MatrixKit/Models/RoomList/MXKSessionRecentsDataSource.h index 51a6cca5..e4a8a4c0 100644 --- a/MatrixKit/Models/RoomList/MXKSessionRecentsDataSource.h +++ b/MatrixKit/Models/RoomList/MXKSessionRecentsDataSource.h @@ -21,6 +21,8 @@ #import "MXKDataSource.h" #import "MXKRecentCellData.h" +@class MXSpace; + /** Identifier to use for cells that display a room in the recents list. */ @@ -54,6 +56,8 @@ extern NSString *const kMXKRecentCellIdentifier; */ @property (nonatomic, readonly) BOOL hasUnread; +@property (nonatomic, strong, nullable) MXSpace *currentSpace; + #pragma mark - Life cycle diff --git a/MatrixKit/Models/RoomList/MXKSessionRecentsDataSource.m b/MatrixKit/Models/RoomList/MXKSessionRecentsDataSource.m index 52a6da52..a912f2f9 100644 --- a/MatrixKit/Models/RoomList/MXKSessionRecentsDataSource.m +++ b/MatrixKit/Models/RoomList/MXKSessionRecentsDataSource.m @@ -18,6 +18,7 @@ #import "MXKSessionRecentsDataSource.h" #import "MXKRoomDataSourceManager.h" +#import #pragma mark - Constant definitions NSString *const kMXKRecentCellIdentifier = @"kMXKRecentCellIdentifier"; @@ -105,6 +106,17 @@ - (void)didMXSessionStateChange } } +- (void)setCurrentSpace:(MXSpace *)currentSpace +{ + if (_currentSpace == currentSpace) + { + return; + } + + _currentSpace = currentSpace; + [self loadData]; +} + #pragma mark - - (NSInteger)numberOfCells @@ -235,7 +247,10 @@ - (void)loadData id cellData = [[class alloc] initWithRoomSummary:roomSummary andRecentListDataSource:self]; if (cellData) { - [internalCellDataArray addObject:cellData]; + if (self.currentSpace == nil || [self.mxSession.spaceService isRoomWithId:roomSummary.roomId descendantOf:self.currentSpace.spaceId]) + { + [internalCellDataArray addObject:cellData]; + } } } }