Merge pull request #158 from blacksigkill/fix/copy-link

fix copy-link action menu
This commit is contained in:
Eduard Prigoana 2026-02-06 17:23:51 +02:00 committed by GitHub
commit 0189a560fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1057,7 +1057,13 @@ export async function handleTrackAction(
navigate(`/album/${item.album.id}`); navigate(`/album/${item.album.id}`);
} }
} else if (action === 'copy-link' || action === 'share') { } else if (action === 'copy-link' || action === 'share') {
const url = `${window.location.origin}/track/${item.id}`; // Use stored href from card if available, otherwise construct URL
const contextMenu = document.getElementById('context-menu');
const storedHref = contextMenu?._contextHref;
const url = storedHref
? `${window.location.origin}${storedHref}`
: `${window.location.origin}/track/${item.id || item.uuid}`;
navigator.clipboard.writeText(url).then(() => { navigator.clipboard.writeText(url).then(() => {
showNotification('Link copied to clipboard!'); showNotification('Link copied to clipboard!');
}); });
@ -1481,6 +1487,7 @@ export function initializeTrackInteractions(player, api, mainContent, contextMen
contextTrack = item; contextTrack = item;
contextMenu._contextTrack = item; contextMenu._contextTrack = item;
contextMenu._contextType = type.replace('userplaylist', 'user-playlist'); contextMenu._contextType = type.replace('userplaylist', 'user-playlist');
contextMenu._contextHref = card.dataset.href;
await updateContextMenuLikeState(contextMenu, item); await updateContextMenuLikeState(contextMenu, item);
positionMenu(contextMenu, e.pageX, e.pageY); positionMenu(contextMenu, e.pageX, e.pageY);