diff --git a/templates/base.gohtml b/templates/base.gohtml index 48ea40b..0751166 100644 --- a/templates/base.gohtml +++ b/templates/base.gohtml @@ -31,13 +31,15 @@ html[data-theme="dark"] .theme-icon-dark { display: none; } html[data-theme="dark"] .theme-icon-light { display: block; } html[data-theme="light"] .theme-icon-light { display: none; } - html[data-theme="light"] .theme-icon-dark { display: block; } + html[data-theme="light"] .theme-icon-dark { display: block; } - - - + + + + + @@ -101,7 +103,7 @@ } } - function toggleWatchlist(id, btn) { + function toggleWatchlist(id, title, btn) { // determine action based on current watchlist state const isInWatchlist = watchlistIds.has(id) const url = isInWatchlist ? `/api/watchlist/${id}` : '/api/watchlist' @@ -118,7 +120,7 @@ watchlistIds.delete(id) btn.classList.remove('in-watchlist') btn.setAttribute('aria-label', 'Add to Watchlist') - if (window.showToast) showToast({ message: 'Removed from watchlist' }) + if (window.showToast) showToast({ message: `Removed ${title} from watchlist` }) // Update dropdown status if on anime page syncWatchlistDropdown(id, false) @@ -126,7 +128,7 @@ watchlistIds.add(id) btn.classList.add('in-watchlist') btn.setAttribute('aria-label', 'Remove from Watchlist') - if (window.showToast) showToast({ message: 'Added to watchlist' }) + if (window.showToast) showToast({ message: `Added ${title} to watchlist` }) // Update dropdown status if on anime page syncWatchlistDropdown(id, true) @@ -168,12 +170,15 @@ if (window.showToast) showToast({ message: 'Something went wrong' }) watchlistIds.delete(id) const card = btn.closest('.group').parentElement if (card) card.remove() + if (window.showToast) showToast({ message: 'Removed from watchlist' }) setTimeout(() => location.reload(), 100) + } else { + if (window.showToast) showToast({ message: 'Failed to update watchlist' }) } }) } - function updateWatchlist(id, status, display, btn) { + function updateWatchlist(id, status, display, title, btn) { fetch('/api/watchlist', { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -196,17 +201,22 @@ if (window.showToast) showToast({ message: 'Something went wrong' }) const dropdown = btn.closest('ui-dropdown'); if (dropdown) dropdown.close(); }); + if (window.showToast) showToast({ message: `Marked ${title} as ${display}` }); + } else { + if (window.showToast) showToast({ message: 'Failed to update watchlist' }); } + }).catch(() => { + if (window.showToast) showToast({ message: 'Something went wrong' }); }); } - function removeWatchlist(id, btn) { + function removeWatchlist(id, title, btn) { fetch('/api/watchlist/' + id, { method: 'DELETE' }).then(res => { if (res.ok) { watchlistIds.delete(id); document.getElementById('watchlist-status-display-' + id).textContent = 'Add to Watchlist'; syncRemoveButtonVisibility(id); - if (window.showToast) showToast({ message: 'Removed from watchlist' }); + if (window.showToast) showToast({ message: `Removed ${title} from watchlist` }); document.querySelectorAll('.watchlist-icon').forEach(function(icon) { const button = icon.closest('button'); if (button) { @@ -220,7 +230,11 @@ if (window.showToast) showToast({ message: 'Something went wrong' }) const dropdown = btn.closest('ui-dropdown'); if (dropdown) dropdown.close(); } + } else { + if (window.showToast) showToast({ message: 'Failed to update watchlist' }); } + }).catch(() => { + if (window.showToast) showToast({ message: 'Something went wrong' }); }); } diff --git a/templates/components/anime_card.gohtml b/templates/components/anime_card.gohtml index ad4dc00..79ad98f 100644 --- a/templates/components/anime_card.gohtml +++ b/templates/components/anime_card.gohtml @@ -35,7 +35,7 @@ {{end}} - + diff --git a/templates/components/watchlist_actions.gohtml b/templates/components/watchlist_actions.gohtml index a123d1b..e1a1340 100644 --- a/templates/components/watchlist_actions.gohtml +++ b/templates/components/watchlist_actions.gohtml @@ -23,21 +23,22 @@ - + Watching - + Completed - + Plan to Watch - + Dropped {{template "watchlist_remove_button" dict "ID" $anime.MalID + "Title" $anime.DisplayTitle "ContainerClass" "hidden" "DividerClass" "my-1 h-px bg-border" "ButtonClass" "flex w-full items-center px-5 py-2.5 transition-colors focus:outline-none hover:bg-red-500/10 focus:bg-red-500/10" @@ -55,7 +56,7 @@ {{define "watchlist_remove_button"}} - + Remove from Watchlist diff --git a/templates/watch.gohtml b/templates/watch.gohtml index 52007b3..f548570 100644 --- a/templates/watch.gohtml +++ b/templates/watch.gohtml @@ -25,20 +25,21 @@ - + Watching - + Completed - + Plan to Watch - + Dropped {{template "watchlist_remove_button" dict "ID" $anime.MalID + "Title" $anime.Title "ContainerClass" "hidden" "DividerClass" "border-t border-border my-1" "ButtonClass" "flex w-full items-center px-5 py-2.5 transition-colors focus:outline-none hover:bg-red-500/10"