Skip to content

Commit 08f09b7

Browse files
committed
feat(delete): confirm before deleting history entries and list items (#122)
1 parent 2a05175 commit 08f09b7

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎frontend/src/components/HistoryCard.astro‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ const href = isEpisode ? episodeHref(media) : `/media/movie/${media.tmdb_id}`;
111111
btn.addEventListener('click', async (e) => {
112112
e.stopPropagation();
113113

114+
const title = card.querySelector('p.text-lg')?.textContent?.trim() || 'this entry';
115+
const ok = await (window as any).showConfirm(`Delete "${title}"?`, 'This removes it from your watch history. This cannot be undone.');
116+
if (!ok) return;
117+
114118
const eventId = card.dataset.eventId;
115119
const token = (window as any).__AUTH_TOKEN__ ?? '';
116120

‎frontend/src/pages/list/[id].astro‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,10 @@ const sonarrUrl = `${origin}/api/proxy/sonarr-compat/${list?.id}`;
506506
btn.dataset.bound = 'true';
507507
btn.addEventListener('click', async (e) => {
508508
e.preventDefault();
509+
const itemTitle = btn.getAttribute('data-item-title') || 'this item';
510+
const ok = await window.showConfirm(`Remove "${itemTitle}"?`, 'This removes it from this list.');
511+
if (!ok) return;
512+
509513
const itemId = btn.getAttribute('data-item-id');
510514
btn.disabled = true;
511515
btn.innerHTML = `<svg class="animate-spin w-3.5 h-3.5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"/><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"/></svg>`;
@@ -767,7 +771,7 @@ const sonarrUrl = `${origin}/api/proxy/sonarr-compat/${list?.id}`;
767771
</div>` : '';
768772

769773
const removeBtn = removeItemId != null
770-
? `<button class="remove-item-btn absolute top-1.5 right-1.5 z-10 w-7 h-7 rounded-lg flex items-center justify-center bg-zinc-950/80 border border-zinc-800 text-zinc-500 hover:text-rose-200 hover:border-rose-700 hover:bg-rose-900 transition-all duration-200 cursor-pointer" data-item-id="${esc(String(removeItemId))}" aria-label="Remove from list">${TRASH_SVG}</button>`
774+
? `<button class="remove-item-btn absolute top-1.5 right-1.5 z-10 w-7 h-7 rounded-lg flex items-center justify-center bg-zinc-950/80 border border-zinc-800 text-zinc-500 hover:text-rose-200 hover:border-rose-700 hover:bg-rose-900 transition-all duration-200 cursor-pointer" data-item-id="${esc(String(removeItemId))}" data-item-title="${esc(cardTitle)}" aria-label="Remove from list">${TRASH_SVG}</button>`
771775
: '';
772776

773777
return `

0 commit comments

Comments
 (0)