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:
commit
086b190308
1 changed files with 14 additions and 16 deletions
30
js/events.js
30
js/events.js
|
|
@ -1633,21 +1633,19 @@ export async function handleTrackAction(
|
||||||
// Use stored href from card if available, otherwise construct URL
|
// Use stored href from card if available, otherwise construct URL
|
||||||
const contextMenu = document.getElementById('context-menu');
|
const contextMenu = document.getElementById('context-menu');
|
||||||
const storedHref = contextMenu?._contextHref;
|
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);
|
trackCopyLink(type, item.id || item.uuid);
|
||||||
navigator.clipboard.writeText(url).then(() => {
|
navigator.clipboard.writeText(url).then(() => {
|
||||||
showNotification('Link copied to clipboard!');
|
showNotification('Link copied to clipboard!');
|
||||||
});
|
});
|
||||||
} else if (action === 'open-in-new-tab') {
|
} 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 contextMenu = document.getElementById('context-menu');
|
||||||
const storedHref = contextMenu?._contextHref;
|
const storedHref = contextMenu?._contextHref;
|
||||||
const contextType = contextMenu?._contextType;
|
const url = storedHref
|
||||||
const url =
|
? `${window.location.origin}${storedHref}`
|
||||||
storedHref && contextType !== 'track'
|
: `${window.location.origin}/${type}/${item.id || item.uuid}`;
|
||||||
? `${window.location.origin}${storedHref}`
|
|
||||||
: `${window.location.origin}/track/${item.id || item.uuid}`;
|
|
||||||
|
|
||||||
trackOpenInNewTab(type, item.id || item.uuid);
|
trackOpenInNewTab(type, item.id || item.uuid);
|
||||||
window.open(url, '_blank');
|
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;">
|
<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>
|
<p style="color: var(--primary); font-weight: 500;">Unreleased Track</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="display: grid; gap: 0.5rem;">
|
<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.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>` : ''}
|
${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.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>` : ''}
|
${item.trackerInfo.recordingDate ? `<p><strong style="color: var(--foreground);">Recording Date:</strong> ${escapeHtml(new Date(item.trackerInfo.recordingDate).toLocaleDateString())}</p>` : ''}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
${
|
${
|
||||||
item.trackerInfo.description
|
item.trackerInfo.description
|
||||||
? `
|
? `
|
||||||
|
|
@ -1701,7 +1699,7 @@ export async function handleTrackAction(
|
||||||
`
|
`
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
${
|
${
|
||||||
item.trackerInfo.notes
|
item.trackerInfo.notes
|
||||||
? `
|
? `
|
||||||
|
|
@ -1712,7 +1710,7 @@ export async function handleTrackAction(
|
||||||
`
|
`
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
${
|
${
|
||||||
item.trackerInfo.sourceUrl
|
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>` : ''}
|
${item.id ? `<p style="margin-top: 1rem; font-size: 0.8rem; color: var(--muted);"><strong>Track ID:</strong> ${escapeHtml(item.id)}</p>` : ''}
|
||||||
</div>
|
</div>
|
||||||
<button class="btn-primary track-info-close-btn" style="margin-top: 1.5rem; width: 100%;">Close</button>
|
<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>` : ''}
|
${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>
|
<p><strong style="color: var(--foreground);">Quality:</strong> ${escapeHtml(quality)} ${bitrate ? `(${escapeHtml(bitrate)})` : ''}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
${
|
${
|
||||||
item.credits && item.credits.length > 0
|
item.credits && item.credits.length > 0
|
||||||
? `
|
? `
|
||||||
|
|
@ -1767,7 +1765,7 @@ export async function handleTrackAction(
|
||||||
`
|
`
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
${
|
${
|
||||||
item.composers && item.composers.length > 0
|
item.composers && item.composers.length > 0
|
||||||
? `
|
? `
|
||||||
|
|
@ -1775,7 +1773,7 @@ export async function handleTrackAction(
|
||||||
`
|
`
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
${
|
${
|
||||||
item.lyrics?.text
|
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.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>` : ''}
|
${item.album?.id ? `<p style="font-size: 0.8rem; color: var(--muted);"><strong>Album ID:</strong> ${escapeHtml(item.album.id)}</p>` : ''}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue