From 1140ecfe41203d3bd70e8b20c22e82f346449bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Tue, 5 May 2026 07:02:08 +0200 Subject: [PATCH] Add buttons for opening signer app, copying connect link --- app/components/nostr-connect.gjs | 51 ++++++++++++++++++++++++++++++-- app/styles/app.css | 8 +++++ 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/app/components/nostr-connect.gjs b/app/components/nostr-connect.gjs index de728ac..16df026 100644 --- a/app/components/nostr-connect.gjs +++ b/app/components/nostr-connect.gjs @@ -41,6 +41,40 @@ export default class NostrConnectComponent extends Component { } } + @action + async copyConnectUri() { + const text = this.nostrAuth.connectUri; + + try { + if (navigator.clipboard && window.isSecureContext) { + await navigator.clipboard.writeText(text); + } else { + const textArea = document.createElement('textarea'); + textArea.value = text; + + textArea.style.position = 'fixed'; + textArea.style.top = '0'; + textArea.style.left = '0'; + textArea.style.opacity = '0'; + + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + + const successful = document.execCommand('copy'); + document.body.removeChild(textArea); + + if (!successful) { + throw new Error('Fallback copy failed'); + } + } + this.toast.show('Connection link copied to clipboard'); + } catch (err) { + console.error('Failed to copy text: ', err); + alert('Failed to copy link'); + } + } +