Skip to content

Commit

Permalink
Add silent sent indication
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Müller <[email protected]>
  • Loading branch information
SystemKeeper committed Sep 19, 2024
1 parent c6ccddb commit 9272dc9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
13 changes: 13 additions & 0 deletions NextcloudTalk/BaseChatTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ class BaseChatTableViewCell: UITableViewCell, ReactionsViewDelegate {
} else {
self.setDeliveryState(to: .sent)
}
} else if message.isSilent {
self.setDeliveryState(to: .silent)
}

let reactionsArray = message.reactionsArray()
Expand Down Expand Up @@ -307,6 +309,17 @@ class BaseChatTableViewCell: UITableViewCell, ReactionsViewDelegate {

self.statusView.addArrangedSubview(errorView)

} else if deliveryState == .silent {
let silentView = UIImageView(frame: .init(x: 0, y: 0, width: 20, height: 20))
var silentImage = UIImage(systemName: "bell.slash")?.withTintColor(.systemGray2).withRenderingMode(.alwaysOriginal)
silentImage = silentImage?.withConfiguration(UIImage.SymbolConfiguration(textStyle: .subheadline))

silentView.image = silentImage
silentView.contentMode = .center
silentView.heightAnchor.constraint(equalToConstant: 20).isActive = true

self.statusView.addArrangedSubview(silentView)

} else if deliveryState == .sent || deliveryState == .read {
var checkImageName = "check"

Expand Down
3 changes: 2 additions & 1 deletion NextcloudTalk/ChatTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ typedef NS_ENUM(NSInteger, ChatMessageDeliveryState) {
ChatMessageDeliveryStateRead,
ChatMessageDeliveryStateSending,
ChatMessageDeliveryStateDeleting,
ChatMessageDeliveryStateFailed
ChatMessageDeliveryStateFailed,
ChatMessageDeliveryStateSilent
};

@protocol ChatTableViewCellDelegate <NSObject>
Expand Down
15 changes: 14 additions & 1 deletion NextcloudTalk/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,7 @@ import UIKit
}

var actions: [UIMenuElement] = []
var informationalActions: [UIMenuElement] = []
let activeAccount = NCDatabaseManager.sharedInstance().activeAccount()
let hasChatPermissions = !NCDatabaseManager.sharedInstance().roomHasTalkCapability(kCapabilityChatPermission, for: room) || (self.room.permissions & NCPermission.chat.rawValue) != 0

Expand All @@ -1604,7 +1605,19 @@ import UIKit
let editInfo = UIAction(title: NSLocalizedString("Edited by", comment: "A message was edited by ...") + " " + lastEditActorDisplayName, attributes: [.disabled], handler: {_ in })
editInfo.subtitle = NCUtils.readableTimeAndDate(fromDate: timestampDate)

actions.append(UIMenu(options: [.displayInline], children: [editInfo]))
informationalActions.append(editInfo)
}

// Show silent send information
if message.isSilent {
let silentInfo = UIAction(title: NSLocalizedString("Sent silently", comment: "A message has been sent silently"), attributes: [.disabled], handler: {_ in })
silentInfo.image = UIImage(systemName: "bell.slash")

informationalActions.append(silentInfo)
}

if !informationalActions.isEmpty {
actions.append(UIMenu(options: [.displayInline], children: informationalActions))
}

// Reply option
Expand Down
1 change: 1 addition & 0 deletions NextcloudTalk/NCChatMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ + (instancetype)messageWithDictionary:(NSDictionary *)messageDict
message.lastEditActorType = [messageDict objectForKey:@"lastEditActorType"];
message.lastEditActorDisplayName = [messageDict objectForKey:@"lastEditActorDisplayName"];
message.lastEditTimestamp = [[messageDict objectForKey:@"lastEditTimestamp"] integerValue];
message.isSilent = [[messageDict objectForKey:@"silent"] boolValue];

id actorDisplayName = [messageDict objectForKey:@"actorDisplayName"];
if (!actorDisplayName) {
Expand Down
3 changes: 3 additions & 0 deletions NextcloudTalk/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,9 @@
/* No comment provided by engineer. */
"Send/Accept" = "Send/Accept";

/* A message has been sent silently */
"Sent silently" = "Sent silently";

/* No comment provided by engineer. */
"Server" = "Server";

Expand Down

0 comments on commit 9272dc9

Please sign in to comment.