Skip to content

Commit

Permalink
Merge pull request #1845 from nextcloud/issue-1816-copy-message-link
Browse files Browse the repository at this point in the history
Added Copy Message Link to context menu actions
  • Loading branch information
Ivansss authored Oct 25, 2024
2 parents 2906ca9 + 1d57c7c commit 4bba72b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
25 changes: 23 additions & 2 deletions NextcloudTalk/BaseChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions NextcloudTalk/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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";

Expand Down

0 comments on commit 4bba72b

Please sign in to comment.