From 02fe7ad753d7fb88e7b362958c8dba9f8e919343 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 19 Mar 2021 15:31:13 +1100 Subject: [PATCH] add a way to copy an open group url --- _locales/en/messages.json | 4 ++++ _locales/fr/messages.json | 8 ++++++++ ts/components/session/menu/Menu.tsx | 7 +++++-- ts/models/conversation.ts | 7 +++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index a871d300f..4fb53c2c7 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1062,6 +1062,10 @@ "description": "Copy to clipboard session ID", "androidKey": "activity_conversation_menu_copy_session_id" }, + "copyOpenGroupURL": { + "message": "Copy Group's URL", + "description": "Copy to clipboard Open Group URL" + }, "save": { "message": "Save", "description": "Used as a 'commit changes' button in the Caption Editor for outgoing image attachments", diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json index 211b2b7df..ce2ede2c3 100644 --- a/_locales/fr/messages.json +++ b/_locales/fr/messages.json @@ -1221,6 +1221,14 @@ "copy": { "message": "Copier" }, + "copySessionID": { + "message": "Copier le Session ID", + "description": "Copy to clipboard session ID" + }, + "copyOpenGroupURL": { + "message": "Copier l'URL de Group", + "description": "Copy to clipboard Open Group URL" + }, "linkPreviewsTitle": { "message": "Envoyer des aperçus de liens" }, diff --git a/ts/components/session/menu/Menu.tsx b/ts/components/session/menu/Menu.tsx index ff9a0725a..30eb5e38f 100644 --- a/ts/components/session/menu/Menu.tsx +++ b/ts/components/session/menu/Menu.tsx @@ -32,8 +32,9 @@ function showDeleteMessages(isPublic: boolean): boolean { return !isPublic; } +// we want to show the copyId for open groups and private chats only function showCopyId(isPublic: boolean, isGroup: boolean): boolean { - return !isGroup; // || isPublic; + return !isGroup || isPublic; } function showDeleteContact( @@ -196,7 +197,9 @@ export function getCopyMenuItem( i18n: LocalizerType ): JSX.Element | null { if (showCopyId(Boolean(isPublic), Boolean(isGroup))) { - const copyIdLabel = i18n('copySessionID'); + const copyIdLabel = isPublic + ? i18n('copyOpenGroupURL') + : i18n('copySessionID'); return {copyIdLabel}; } return null; diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index a5f73b657..1c93332ba 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -1351,6 +1351,13 @@ export class ConversationModel extends Backbone.Model { } public copyPublicKey() { + if (this.isPublic()) { + const openGroupUrl = this.id.substr(this.id.indexOf('@') + 1); + window.clipboard.writeText(openGroupUrl); + + ToastUtils.pushCopiedToClipBoard(); + return; + } window.clipboard.writeText(this.id); ToastUtils.pushCopiedToClipBoard();