Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,11 @@ export default {
},

handleCopyMessageLink() {
copyConversationLinkToClipboard(this.message.token, this.message.id)
if (this.message.isThread && this.message.id !== this.message.threadId) {
copyConversationLinkToClipboard(this.message.token, this.message.id, this.message.threadId)
} else {
copyConversationLinkToClipboard(this.message.token, this.message.id)
}
},

async handleMarkAsUnread() {
Expand Down
18 changes: 14 additions & 4 deletions src/utils/handleUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ export function generateAbsoluteUrl(url: string, params?: object, options: UrlOp
*
* @param token - Conversation token
* @param [messageId] - messageId for message in conversation link
* @param [threadId] - threadId for message in conversation link
*/
export function generateFullConversationLink(token: string, messageId?: string): string {
export function generateFullConversationLink(token: string, messageId?: string, threadId?: string): string {
if (threadId && messageId) {
return generateAbsoluteUrl('/call/{token}?threadId={threadId}#message_{messageId}', { token, messageId, threadId })
}

return messageId !== undefined
? generateAbsoluteUrl('/call/{token}#message_{messageId}', { token, messageId })
: generateAbsoluteUrl('/call/{token}', { token })
Expand All @@ -41,11 +46,16 @@ export function generateFullConversationLink(token: string, messageId?: string):
*
* @param token - conversation token
* @param [messageId] - messageId for message in conversation link
* @param [threadId] - threadId for message in conversation link
*/
export async function copyConversationLinkToClipboard(token: string, messageId?: string) {
export async function copyConversationLinkToClipboard(token: string, messageId?: string, threadId?: string) {
try {
await navigator.clipboard.writeText(generateFullConversationLink(token, messageId))
showSuccess(t('spreed', 'Conversation link copied to clipboard'))
await navigator.clipboard.writeText(generateFullConversationLink(token, messageId, threadId))
if (messageId) {
showSuccess(t('spreed', 'Message link copied to clipboard'))
} else {
showSuccess(t('spreed', 'Conversation link copied to clipboard'))
}
} catch (error) {
showError(t('spreed', 'The link could not be copied'))
}
Expand Down
Loading