Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add silent sent indication #1808

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading