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

Added Copy Message Link to context menu actions #1845

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
Loading