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
12
js/events.js
12
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');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue