diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 98c1ef585..64b115a23 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -1849,6 +1849,7 @@ Tap the + to start adding people."; "home_context_menu_low_priority" = "Low priority"; "home_context_menu_normal_priority" = "Normal priority"; "home_context_menu_leave" = "Leave"; +"home_context_menu_mark_as_read" = "Mark as read"; "home_syncing" = "Syncing"; // MARK: - Favourites diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index cd6a7b56c..a40347d7c 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -2063,6 +2063,10 @@ public class VectorL10n: NSObject { public static var homeContextMenuMakeRoom: String { return VectorL10n.tr("Vector", "home_context_menu_make_room") } + /// Mark as read + public static var homeContextMenuMarkAsRead: String { + return VectorL10n.tr("Vector", "home_context_menu_mark_as_read") + } /// Mute public static var homeContextMenuMute: String { return VectorL10n.tr("Vector", "home_context_menu_mute") diff --git a/Riot/Modules/ContextMenu/ActionProviders/RoomActionProvider.swift b/Riot/Modules/ContextMenu/ActionProviders/RoomActionProvider.swift index 12ec1c9e1..7d12f8878 100644 --- a/Riot/Modules/ContextMenu/ActionProviders/RoomActionProvider.swift +++ b/Riot/Modules/ContextMenu/ActionProviders/RoomActionProvider.swift @@ -34,13 +34,15 @@ class RoomActionProvider: RoomActionProviderProtocol { var menu: UIMenu { if service.isRoomJoined { - return UIMenu(children: [ + var children = service.hasUnread ? [self.markAsReadAction] : [] + children.append(contentsOf: [ self.directChatAction, self.notificationsAction, self.favouriteAction, self.lowPriorityAction, self.leaveAction ]) + return UIMenu(children: children) } else { if service.roomMembership == .invite { return UIMenu(children: [ @@ -103,6 +105,15 @@ class RoomActionProvider: RoomActionProviderProtocol { } } + private var markAsReadAction: UIAction { + return UIAction( + title: VectorL10n.homeContextMenuMarkAsRead, + image: UIImage(systemName: "envelope.open")) { [weak self] action in + guard let self = self else { return } + self.service.markAsRead() + } + } + private var leaveAction: UIAction { let image = UIImage(systemName: "rectangle.righthalf.inset.fill.arrow.right") let action = UIAction(title: VectorL10n.homeContextMenuLeave, image: image) { [weak self] action in diff --git a/Riot/Modules/ContextMenu/Services/RoomContextActionService.swift b/Riot/Modules/ContextMenu/Services/RoomContextActionService.swift index add4db41e..c3abab55b 100644 --- a/Riot/Modules/ContextMenu/Services/RoomContextActionService.swift +++ b/Riot/Modules/ContextMenu/Services/RoomContextActionService.swift @@ -38,6 +38,7 @@ class RoomContextActionService: NSObject, RoomContextActionServiceProtocol { self.room = room self.delegate = delegate self.isRoomJoined = room.summary?.isJoined ?? false + self.hasUnread = room.summary?.hasAnyUnread ?? false self.roomMembership = room.summary?.membership ?? .unknown self.session = room.mxSession self.unownedRoomService = UnownedRoomContextActionService(roomId: room.roomId, canonicalAlias: room.summary?.aliases?.first, session: self.session, delegate: delegate) @@ -46,6 +47,7 @@ class RoomContextActionService: NSObject, RoomContextActionServiceProtocol { // MARK: - Public let isRoomJoined: Bool + let hasUnread: Bool let roomMembership: MXMembership var isRoomDirect: Bool { @@ -104,6 +106,12 @@ class RoomContextActionService: NSObject, RoomContextActionServiceProtocol { } } + func markAsRead() { + room.markAllAsRead() + } + + // MARK: - Private + private func muteRoomNotifications(_ isMuted: Bool) { self.delegate?.roomContextActionService(self, updateActivityIndicator: true) if isMuted { diff --git a/changelog.d/6278.feature b/changelog.d/6278.feature new file mode 100644 index 000000000..2767fddac --- /dev/null +++ b/changelog.d/6278.feature @@ -0,0 +1 @@ +Added "Mark as read" option to the room context menu.