RecentsDataSource: Remove InviteRecentTableViewCell dependency

This commit is contained in:
giomfo
2016-04-28 16:26:37 +02:00
parent 1b2b5ab475
commit 32b61335fc
11 changed files with 97 additions and 92 deletions
+36 -21
View File
@@ -296,30 +296,45 @@
return;
}
if ([dataSource isKindOfClass:[RecentsDataSource class]])
{
RecentsDataSource* recentsDataSource = (RecentsDataSource*)dataSource;
recentsDataSource.onRoomInvitationReject = ^(MXRoom* room) {
[self setEditing:NO];
[room leave:^{
[self.recentsTableView reloadData];
} failure:^(NSError *error) {
NSLog(@"[RecentsViewController] Failed to reject an invited room (%@) failed", room.state.roomId);
}];
};
recentsDataSource.onRoomInvitationAccept = ^(MXRoom* room) {
[self.delegate recentListViewController:self didSelectRoom:room.state.roomId inMatrixSession:room.mxSession];
};
}
[self refreshRecentsTable];
}
- (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)actionIdentifier inCell:(id<MXKCellRendering>)cell userInfo:(NSDictionary *)userInfo
{
// Handle here user actions on recents for Vector app
if ([actionIdentifier isEqualToString:kInviteRecentTableViewCellPreviewButtonPressed])
{
// Retrieve the invited room
MXRoom *invitedRoom = userInfo[kInviteRecentTableViewCellRoomKey];
// Display room preview by selecting it.
[self.delegate recentListViewController:self didSelectRoom:invitedRoom.state.roomId inMatrixSession:invitedRoom.mxSession];
}
else if ([actionIdentifier isEqualToString:kInviteRecentTableViewCellDeclineButtonPressed])
{
// Retrieve the invited room
MXRoom *invitedRoom = userInfo[kInviteRecentTableViewCellRoomKey];
[self setEditing:NO];
// Decline the invitation
[invitedRoom leave:^{
[self.recentsTableView reloadData];
} failure:^(NSError *error) {
NSLog(@"[RecentsViewController] Failed to reject an invited room (%@) failed", invitedRoom.state.roomId);
}];
}
else
{
// Keep default implementation for other actions
[super dataSource:dataSource didRecognizeAction:actionIdentifier inCell:cell userInfo:userInfo];
}
}
#pragma mark - swipe actions
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath