Merge pull request #7301 from vector-im/flescio/7253-Add_mar_kas_unread_option_for_rooms

Flescio/7253 add mar kas unread option for rooms
This commit is contained in:
Flescio 2023-01-31 12:37:40 +01:00 committed by GitHub
commit 54602b63ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 39 additions and 5 deletions

View file

@ -2000,6 +2000,7 @@ Tap the + to start adding people.";
"home_context_menu_normal_priority" = "Normal priority";
"home_context_menu_leave" = "Leave";
"home_context_menu_mark_as_read" = "Mark as read";
"home_context_menu_mark_as_unread" = "Mark as unread";
"home_syncing" = "Syncing";
// MARK: - Favourites

View file

@ -2515,6 +2515,10 @@ public class VectorL10n: NSObject {
public static var homeContextMenuMarkAsRead: String {
return VectorL10n.tr("Vector", "home_context_menu_mark_as_read")
}
/// Mark as unread
public static var homeContextMenuMarkAsUnread: String {
return VectorL10n.tr("Vector", "home_context_menu_mark_as_unread")
}
/// Mute
public static var homeContextMenuMute: String {
return VectorL10n.tr("Vector", "home_context_menu_mute")

View file

@ -2471,6 +2471,11 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
editedRoomId = nil;
}
-(void)roomContextActionServiceDidMarkRoom:(id<RoomContextActionServiceProtocol>)service
{
[self refreshRecentsTable];
}
#pragma mark - RecentCellContextMenuProviderDelegate
- (void)recentCellContextMenuProviderDidStartShowingPreview:(RecentCellContextMenuProvider *)menuProvider

View file

@ -69,6 +69,7 @@
self.missedNotifAndUnreadIndicator.hidden = YES;
self.missedNotifAndUnreadBadgeBgView.hidden = YES;
self.missedNotifAndUnreadBadgeBgViewWidthConstraint.constant = 0;
self.missedNotifAndUnreadBadgeLabel.text = @"";
roomCellData = (id<MXKRecentCellDataStoring>)cellData;
if (roomCellData)
@ -93,10 +94,10 @@
// Notify unreads and bing
if (roomCellData.hasUnread)
{
self.missedNotifAndUnreadIndicator.hidden = NO;
if (0 < roomCellData.notificationCount)
{
self.missedNotifAndUnreadIndicator.hidden = NO;
self.missedNotifAndUnreadIndicator.backgroundColor = roomCellData.highlightCount ? ThemeService.shared.theme.noticeColor : ThemeService.shared.theme.noticeSecondaryColor;
self.missedNotifAndUnreadBadgeBgView.hidden = NO;
@ -109,7 +110,9 @@
}
else
{
self.missedNotifAndUnreadIndicator.backgroundColor = ThemeService.shared.theme.unreadRoomIndentColor;
self.missedNotifAndUnreadBadgeBgView.hidden = NO;
self.missedNotifAndUnreadBadgeBgView.backgroundColor = ThemeService.shared.theme.tintColor;
self.missedNotifAndUnreadBadgeBgViewWidthConstraint.constant = 20;
}
// Use bold font for the room title

View file

@ -34,7 +34,7 @@ class RoomActionProvider: RoomActionProviderProtocol {
var menu: UIMenu {
if service.isRoomJoined {
var children = service.hasUnread ? [self.markAsReadAction] : []
var children = service.hasUnread ? [self.markAsReadAction] : [self.markAsUnreadAction]
children.append(contentsOf: [
self.directChatAction,
self.notificationsAction,
@ -113,6 +113,14 @@ class RoomActionProvider: RoomActionProviderProtocol {
self.service.markAsRead()
}
}
private var markAsUnreadAction: UIAction {
return UIAction(
title: VectorL10n.homeContextMenuMarkAsUnread,
image: UIImage(systemName: "envelope.badge")) { [weak self] action in
guard let self = self else { return }
self.service.markAsUnread()
}
}
private var leaveAction: UIAction {
let image = UIImage(systemName: "rectangle.righthalf.inset.fill.arrow.right")

View file

@ -38,7 +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.hasUnread = (room.summary?.hasAnyUnread ?? false) || room.isMarkedAsUnread
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)
@ -108,6 +108,11 @@ class RoomContextActionService: NSObject, RoomContextActionServiceProtocol {
func markAsRead() {
room.markAllAsRead()
self.delegate?.roomContextActionServiceDidMarkRoom(self)
}
func markAsUnread() {
room.setUnread()
self.delegate?.roomContextActionServiceDidMarkRoom(self)
}
// MARK: - Private

View file

@ -22,6 +22,7 @@ import Foundation
func roomContextActionService(_ service: RoomContextActionServiceProtocol, showRoomNotificationSettingsForRoomWithId roomId: String)
func roomContextActionServiceDidJoinRoom(_ service: RoomContextActionServiceProtocol)
func roomContextActionServiceDidLeaveRoom(_ service: RoomContextActionServiceProtocol)
func roomContextActionServiceDidMarkRoom(_ service: RoomContextActionServiceProtocol)
}
/// `RoomContextActionServiceProtocol` classes are meant to be called by a `RoomActionProviderProtocol` instance so it provides the implementation of the menu actions.

View file

@ -63,7 +63,8 @@
- (BOOL)hasUnread
{
return (roomSummary.localUnreadEventCount != 0);
bool isRoomUnread = [[self mxSession] isRoomMarkedAsUnread:roomSummary.roomId];
return (roomSummary.localUnreadEventCount != 0 || isRoomUnread);
}
- (NSString *)roomIdentifier

View file

@ -370,6 +370,11 @@
[self.roomDataSource.room.summary markAllAsReadLocally];
[self updateCurrentEventIdAtTableBottom:YES];
if (!self.isContextPreview)
{
[self.roomDataSource.room resetUnread];
}
}
- (void)viewWillDisappear:(BOOL)animated

1
changelog.d/7253.feature Normal file
View file

@ -0,0 +1 @@
Add mark as unread option for rooms