heisbuba commited on
Commit
15a42e3
·
verified ·
1 Parent(s): 74d8c20

Update src/templates/reports/watchlist.html

Browse files
Files changed (1) hide show
  1. src/templates/reports/watchlist.html +19 -10
src/templates/reports/watchlist.html CHANGED
@@ -339,16 +339,25 @@
339
  async function deleteCurrent() {
340
  if (!currentCoin || !confirm('Permanently remove research?')) return;
341
  const targetId = currentCoin.coin_id;
342
- watchlistData = watchlistData.filter(c => c.coin_id !== targetId);
343
-
344
- renderBubbles();
345
- closeOverlay();
346
-
347
- await fetch('/api/watchlist/toggle', {
348
- method: 'POST',
349
- headers: {'Content-Type': 'application/json'},
350
- body: JSON.stringify({ coin_id: targetId, action: 'remove' })
351
- });
 
 
 
 
 
 
 
 
 
352
  }
353
  document.addEventListener('DOMContentLoaded', renderBubbles);
354
  </script>
 
339
  async function deleteCurrent() {
340
  if (!currentCoin || !confirm('Permanently remove research?')) return;
341
  const targetId = currentCoin.coin_id;
342
+
343
+ try {
344
+ const res = await fetch('/api/watchlist/toggle', {
345
+ method: 'POST',
346
+ headers: {'Content-Type': 'application/json'},
347
+ body: JSON.stringify({ coin_id: targetId, action: 'remove' })
348
+ });
349
+ const data = await res.json();
350
+ if (res.ok && data.status === 'success') {
351
+ watchlistData = watchlistData.filter(c => c.coin_id !== targetId);
352
+ renderBubbles();
353
+ closeOverlay();
354
+ } else {
355
+ alert('Failed to remove from watchlist. Please try again.');
356
+ }
357
+ } catch(e) {
358
+ console.error('Watchlist delete error:', e);
359
+ alert('Connection error. Please try again.');
360
+ }
361
  }
362
  document.addEventListener('DOMContentLoaded', renderBubbles);
363
  </script>