diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index 73a73bd15..6b118ffa7 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -1304,6 +1304,24 @@ - (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView tra leaveImage = [leaveImage vc_tintedImageUsingColor:selectedColor]; leaveAction.image = [leaveImage vc_notRenderedImage]; + //Tchap: mark room as read action + UIContextualAction *markAllAsReadAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive + title:title + handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) { + [self markAllAsReadInEditedRoom]; + + self->editedRoomId = nil; // Tchap: Reset editedRoomId else UI content does not refresh anymore. + + completionHandler(YES); + }]; + markAllAsReadAction.backgroundColor = actionBackgroundColor; + + UIImage *markAllAsReadImage = [UIImage systemImageNamed:@"envelope.open"]; + markAllAsReadImage = [markAllAsReadImage vc_tintedImageUsingColor:selectedColor]; + markAllAsReadAction.image = [markAllAsReadImage vc_notRenderedImage]; + + + // Create swipe action configuration // Tchap: Disable unavailable actions in Tchap NSArray *actions = @[ @@ -1311,7 +1329,8 @@ - (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView tra //priorityAction, favouriteAction, muteAction, - //directChatAction + //directChatAction, + markAllAsReadAction // Tchap: mark all as read local action ]; UISwipeActionsConfiguration *swipeActionConfiguration = [UISwipeActionsConfiguration configurationWithActions:actions]; @@ -1644,6 +1663,25 @@ - (void)muteEditedRoomNotifications:(BOOL)mute } } +// Tchap: mark room as read action +- (void)markAllAsReadInEditedRoom +{ + if (editedRoomId) + { + // Check whether the user didn't leave the room + MXRoom *room = [self.mainSession roomWithRoomId:editedRoomId]; + if (room) + { + [room markAllAsRead]; + } + else + { + // Leave editing mode + [self cancelEditionMode:isRefreshPending]; + } + } +} + #pragma mark - UITableView delegate - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath; diff --git a/changelog.d/1053.feature b/changelog.d/1053.feature new file mode 100644 index 000000000..97ab150cd --- /dev/null +++ b/changelog.d/1053.feature @@ -0,0 +1 @@ +Ajouter une action "Marquer comme lu" sur un salon \ No newline at end of file