mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 15:22:39 +00:00
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:
commit
54602b63ec
10 changed files with 39 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -2471,6 +2471,11 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
|
|||
editedRoomId = nil;
|
||||
}
|
||||
|
||||
-(void)roomContextActionServiceDidMarkRoom:(id<RoomContextActionServiceProtocol>)service
|
||||
{
|
||||
[self refreshRecentsTable];
|
||||
}
|
||||
|
||||
#pragma mark - RecentCellContextMenuProviderDelegate
|
||||
|
||||
- (void)recentCellContextMenuProviderDidStartShowingPreview:(RecentCellContextMenuProvider *)menuProvider
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -63,7 +63,8 @@
|
|||
|
||||
- (BOOL)hasUnread
|
||||
{
|
||||
return (roomSummary.localUnreadEventCount != 0);
|
||||
bool isRoomUnread = [[self mxSession] isRoomMarkedAsUnread:roomSummary.roomId];
|
||||
return (roomSummary.localUnreadEventCount != 0 || isRoomUnread);
|
||||
}
|
||||
|
||||
- (NSString *)roomIdentifier
|
||||
|
|
|
@ -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
1
changelog.d/7253.feature
Normal file
|
@ -0,0 +1 @@
|
|||
Add mark as unread option for rooms
|
Loading…
Reference in a new issue