Skip to content

Commit

Permalink
Merge pull request #1054 from tchapgouv/1053-ajouter-une-option-marqu…
Browse files Browse the repository at this point in the history
…er-comme-lu-sur-un-salon

Ajouter une action "Marquer comme lu" sur un salon
  • Loading branch information
NicolasBuquet authored Jun 6, 2024
2 parents d3da1d4 + 73402c3 commit e8ec0a4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
40 changes: 39 additions & 1 deletion Riot/Modules/Common/Recents/RecentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1304,14 +1304,33 @@ - (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<UIContextualAction*> *actions = @[
leaveAction,
//priorityAction,
favouriteAction,
muteAction,
//directChatAction
//directChatAction,
markAllAsReadAction // Tchap: mark all as read local action
];

UISwipeActionsConfiguration *swipeActionConfiguration = [UISwipeActionsConfiguration configurationWithActions:actions];
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1053.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ajouter une action "Marquer comme lu" sur un salon

0 comments on commit e8ec0a4

Please sign in to comment.