Skip to content

Commit ddbed3f

Browse files
Copilotmuke1908
andauthored
feat: copy full URL from chat header and add native share button (#440)
Agent-Logs-Url: https://github.com/muke1908/chat-e2ee/sessions/aaf031fd-38c1-40b8-93a8-98cdd0751d7f Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: muke1908 <20297989+muke1908@users.noreply.github.com>
1 parent cf2f24a commit ddbed3f

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

client/app.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const participantInfo = document.getElementById('participant-info')!;
3434
const headerHashDisplay = document.getElementById('channel-hash-display')!;
3535
const headerHashText = document.getElementById('header-hash')!;
3636
const copyHeaderHashBtn = document.getElementById('copy-header-hash') as HTMLButtonElement;
37+
const shareBtn = document.getElementById('share-btn') as HTMLButtonElement;
3738

3839
// Call Elements
3940
const callOverlay = document.getElementById('call-overlay')!;
@@ -132,12 +133,23 @@ copyHashBtn.addEventListener('click', () => {
132133
});
133134

134135
copyHeaderHashBtn.addEventListener('click', () => {
135-
navigator.clipboard.writeText(headerHashText.textContent || '');
136+
navigator.clipboard.writeText(window.location.href);
136137
const originalText = setupStatus.textContent;
137-
setupStatus.textContent = 'Hash copied to clipboard!';
138+
setupStatus.textContent = 'URL copied to clipboard!';
138139
setTimeout(() => setupStatus.textContent = originalText, 2000);
139140
});
140141

142+
if ('share' in navigator) {
143+
shareBtn.classList.remove('hidden');
144+
shareBtn.addEventListener('click', () => {
145+
navigator.share({
146+
title: 'Chat E2EE',
147+
text: 'Join my end-to-end encrypted chat',
148+
url: window.location.href,
149+
}).catch(() => { /* user cancelled or share failed */ });
150+
});
151+
}
152+
141153
async function checkExistingUsers() {
142154
try {
143155
const users = await chat.getUsersInChannel();

client/index.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ <h2 id="channel-title">Secure Channel</h2>
6969
</div>
7070
<div id="channel-hash-display" class="hash-badge-container hidden">
7171
<span id="header-hash" class="hash-text"></span>
72-
<button id="copy-header-hash" class="icon-btn tiny" title="Copy Hash">
72+
<button id="copy-header-hash" class="icon-btn tiny" title="Copy Link">
7373
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
7474
stroke-linecap="round" stroke-linejoin="round">
7575
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
@@ -80,6 +80,16 @@ <h2 id="channel-title">Secure Channel</h2>
8080
<p id="participant-info">Waiting for someone to join...</p>
8181
</div>
8282
<div class="header-actions">
83+
<button id="share-btn" title="Share Link" class="icon-btn hidden">
84+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
85+
stroke-linecap="round" stroke-linejoin="round">
86+
<circle cx="18" cy="5" r="3"></circle>
87+
<circle cx="6" cy="12" r="3"></circle>
88+
<circle cx="18" cy="19" r="3"></circle>
89+
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"></line>
90+
<line x1="15.41" y1="6.51" x2="8.59" y2="10.49"></line>
91+
</svg>
92+
</button>
8393
<button id="start-call-btn" title="Start Audio Call" class="icon-btn">
8494
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
8595
stroke-linecap="round" stroke-linejoin="round">

0 commit comments

Comments
 (0)