diff --git a/NextcloudTalk/BaseChatViewController.swift b/NextcloudTalk/BaseChatViewController.swift index 0e4f2e68d..d7abc71cc 100644 --- a/NextcloudTalk/BaseChatViewController.swift +++ b/NextcloudTalk/BaseChatViewController.swift @@ -964,6 +964,18 @@ import QuickLook NotificationPresenter.shared().present(text: NSLocalizedString("Message copied", comment: ""), dismissAfterDelay: 5.0, includedStyle: .dark) } + func didPressCopyLink(for message: NCChatMessage) { + guard let link = room.linkURL else { + return + } + + let url = "\(link)#message_\(message.messageId)" + let pasteboard = UIPasteboard.general + pasteboard.string = url + + NotificationPresenter.shared().present(text: NSLocalizedString("Message link copied", comment: ""), dismissAfterDelay: 5.0, includedStyle: .dark) + } + func didPressTranslate(for message: NCChatMessage) { let activeAccount = NCDatabaseManager.sharedInstance().activeAccount() let translateMessageVC = MessageTranslationViewController(message: message.parsedMessage().string, availableTranslations: NCDatabaseManager.sharedInstance().availableTranslations(forAccountId: activeAccount.accountId)) @@ -2821,10 +2833,19 @@ import QuickLook return nil } + var actions: [UIMenuElement] = [] + // Copy option - let menu = UIMenu(children: [UIAction(title: NSLocalizedString("Copy", comment: ""), image: .init(systemName: "square.on.square")) { _ in + actions.append(UIAction(title: NSLocalizedString("Copy", comment: ""), image: .init(systemName: "square.on.square")) { _ in self.didPressCopy(for: message) - }]) + }) + + // Copy Link + actions.append(UIAction(title: NSLocalizedString("Copy message link", comment: ""), image: .init(systemName: "link")) { _ in + self.didPressCopyLink(for: message) + }) + + let menu = UIMenu(children: actions) let configuration = UIContextMenuConfiguration(identifier: indexPath as NSIndexPath) { return nil diff --git a/NextcloudTalk/en.lproj/Localizable.strings b/NextcloudTalk/en.lproj/Localizable.strings index 779ab84aa..366d54722 100644 --- a/NextcloudTalk/en.lproj/Localizable.strings +++ b/NextcloudTalk/en.lproj/Localizable.strings @@ -487,6 +487,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* No comment provided by engineer. */ +"Copy message link" = "Copy message link"; + /* No comment provided by engineer. */ "Could not access camera" = "Could not access camera"; @@ -1096,6 +1099,9 @@ /* No comment provided by engineer. */ "Message expiration time" = "Message expiration time"; +/* No comment provided by engineer. */ +"Message link copied" = "Message link copied"; + /* No comment provided by engineer. */ "Messages" = "Messages";