Merge pull request #366 from matioku/fix/share-url-construction

fix(events): fix share/open-in-new-tab URL construction
This commit is contained in:
edidealt 2026-03-20 22:57:53 +00:00
commit 086b190308

View file

@ -1633,21 +1633,19 @@ export async function handleTrackAction(
// Use stored href from card if available, otherwise construct URL
const contextMenu = document.getElementById('context-menu');
const storedHref = contextMenu?._contextHref;
const url = getShareUrl(storedHref ? storedHref : `/track/${item.id || item.uuid}`);
const url = getShareUrl(storedHref ? storedHref : `/${type}/${item.id || item.uuid}`);
trackCopyLink(type, item.id || item.uuid);
navigator.clipboard.writeText(url).then(() => {
showNotification('Link copied to clipboard!');
});
} else if (action === 'open-in-new-tab') {
// Use stored href from card if available and not a track, otherwise construct URL
// Use stored href from card if available, otherwise construct URL
const contextMenu = document.getElementById('context-menu');
const storedHref = contextMenu?._contextHref;
const contextType = contextMenu?._contextType;
const url =
storedHref && contextType !== 'track'
? `${window.location.origin}${storedHref}`
: `${window.location.origin}/track/${item.id || item.uuid}`;
const url = storedHref
? `${window.location.origin}${storedHref}`
: `${window.location.origin}/${type}/${item.id || item.uuid}`;
trackOpenInNewTab(type, item.id || item.uuid);
window.open(url, '_blank');
@ -1675,7 +1673,7 @@ export async function handleTrackAction(
<div style="margin-bottom: 1rem; padding: 0.75rem; background: var(--accent); border-radius: 8px;">
<p style="color: var(--primary); font-weight: 500;">Unreleased Track</p>
</div>
<div style="display: grid; gap: 0.5rem;">
${item.artists ? `<p><strong style="color: var(--foreground);">Artist:</strong> ${escapeHtml(Array.isArray(item.artists) ? item.artists.map((a) => a.name || a).join(', ') : item.artists)}</p>` : ''}
${item.trackerInfo.artist ? `<p><strong style="color: var(--foreground);">Tracked Artist:</strong> ${escapeHtml(item.trackerInfo.artist)}</p>` : ''}
@ -1690,7 +1688,7 @@ export async function handleTrackAction(
${item.trackerInfo.leakedDate ? `<p><strong style="color: var(--foreground);">Leak Date:</strong> ${escapeHtml(new Date(item.trackerInfo.leakedDate).toLocaleDateString())}</p>` : ''}
${item.trackerInfo.recordingDate ? `<p><strong style="color: var(--foreground);">Recording Date:</strong> ${escapeHtml(new Date(item.trackerInfo.recordingDate).toLocaleDateString())}</p>` : ''}
</div>
${
item.trackerInfo.description
? `
@ -1701,7 +1699,7 @@ export async function handleTrackAction(
`
: ''
}
${
item.trackerInfo.notes
? `
@ -1712,7 +1710,7 @@ export async function handleTrackAction(
`
: ''
}
${
item.trackerInfo.sourceUrl
? `
@ -1725,7 +1723,7 @@ export async function handleTrackAction(
`
: ''
}
${item.id ? `<p style="margin-top: 1rem; font-size: 0.8rem; color: var(--muted);"><strong>Track ID:</strong> ${escapeHtml(item.id)}</p>` : ''}
</div>
<button class="btn-primary track-info-close-btn" style="margin-top: 1.5rem; width: 100%;">Close</button>
@ -1754,7 +1752,7 @@ export async function handleTrackAction(
${item.explicit ? `<p><strong style="color: var(--foreground);">Explicit:</strong> Yes</p>` : ''}
<p><strong style="color: var(--foreground);">Quality:</strong> ${escapeHtml(quality)} ${bitrate ? `(${escapeHtml(bitrate)})` : ''}</p>
</div>
${
item.credits && item.credits.length > 0
? `
@ -1767,7 +1765,7 @@ export async function handleTrackAction(
`
: ''
}
${
item.composers && item.composers.length > 0
? `
@ -1775,7 +1773,7 @@ export async function handleTrackAction(
`
: ''
}
${
item.lyrics?.text
? `
@ -1785,7 +1783,7 @@ export async function handleTrackAction(
`
: ''
}
${item.id ? `<p style="margin-top: 1rem; font-size: 0.8rem; color: var(--muted);"><strong>Track ID:</strong> ${escapeHtml(item.id)}</p>` : ''}
${item.album?.id ? `<p style="font-size: 0.8rem; color: var(--muted);"><strong>Album ID:</strong> ${escapeHtml(item.album.id)}</p>` : ''}
</div>