fix(dashboard): make thumbs-down dismiss a single story
This commit is contained in:
@@ -280,7 +280,7 @@ def card(i:dict[str,Any], compact:bool=False)->str:
|
|||||||
feedback_html='' if not compact else (
|
feedback_html='' if not compact else (
|
||||||
f"<div class='feedback'>"
|
f"<div class='feedback'>"
|
||||||
f"<button type='button' class='feedback-btn' data-feedback='up' aria-pressed='false' title='Prefer more {esc(topic)} stories'>👍</button>"
|
f"<button type='button' class='feedback-btn' data-feedback='up' aria-pressed='false' title='Prefer more {esc(topic)} stories'>👍</button>"
|
||||||
f"<button type='button' class='feedback-btn' data-feedback='down' aria-pressed='false' title='Hide this story and de-prioritize {esc(topic)}'>👎</button>"
|
f"<button type='button' class='feedback-btn' data-feedback='down' aria-pressed='false' title='Less like this — hide this story'>👎</button>"
|
||||||
f"</div>"
|
f"</div>"
|
||||||
)
|
)
|
||||||
return f"""<article class='{cls} {esc(i.get('category',''))}' data-topic='{esc(topic)}' data-source='{esc(source)}' data-domain='{esc(domain)}'>
|
return f"""<article class='{cls} {esc(i.get('category',''))}' data-topic='{esc(topic)}' data-source='{esc(source)}' data-domain='{esc(domain)}'>
|
||||||
@@ -440,15 +440,12 @@ def feedback_bootstrap()->str:
|
|||||||
cards.forEach(card=>{
|
cards.forEach(card=>{
|
||||||
const topic=card.dataset.topic||'other';
|
const topic=card.dataset.topic||'other';
|
||||||
const hidden=(prefs.hidden||[]).includes(topic) || hiddenCards.includes(card.dataset.cardId||'');
|
const hidden=(prefs.hidden||[]).includes(topic) || hiddenCards.includes(card.dataset.cardId||'');
|
||||||
const downMuted=(prefs.hidden||[]).includes(topic);
|
|
||||||
card.style.display=hidden?'none':'';
|
card.style.display=hidden?'none':'';
|
||||||
card.classList.remove('topic-liked');
|
card.classList.remove('topic-liked');
|
||||||
card.querySelectorAll('[data-feedback]').forEach(btn=>{
|
card.querySelectorAll('[data-feedback]').forEach(btn=>{
|
||||||
const mode=btn.dataset.feedback;
|
btn.setAttribute('aria-pressed', 'false');
|
||||||
const pressed=(mode==='down' && downMuted);
|
|
||||||
btn.setAttribute('aria-pressed', pressed ? 'true' : 'false');
|
|
||||||
btn.classList.toggle('active-up', false);
|
btn.classList.toggle('active-up', false);
|
||||||
btn.classList.toggle('active-down', mode==='down' && downMuted);
|
btn.classList.toggle('active-down', false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const badge=document.querySelector('[data-hidden-topics-count]');
|
const badge=document.querySelector('[data-hidden-topics-count]');
|
||||||
@@ -473,10 +470,8 @@ def feedback_bootstrap()->str:
|
|||||||
lastAction={prefs:JSON.parse(JSON.stringify(prefs)), hiddenCards:[...hiddenCards]};
|
lastAction={prefs:JSON.parse(JSON.stringify(prefs)), hiddenCards:[...hiddenCards]};
|
||||||
hiddenCards=hiddenCards.filter(x=>x!==id);
|
hiddenCards=hiddenCards.filter(x=>x!==id);
|
||||||
hiddenCards.push(id);
|
hiddenCards.push(id);
|
||||||
prefs.hidden=(prefs.hidden||[]).filter(x=>x!==topic);
|
|
||||||
prefs.hidden.push(topic);
|
|
||||||
saveHiddenCards(hiddenCards);
|
saveHiddenCards(hiddenCards);
|
||||||
setToast(`Hid this story and muted <strong>${topic}</strong> for later. <button type="button" class="toast-action" data-undo-topic>Undo</button>`);
|
setToast(`Right — less <strong>${topic}</strong> like this, and this story’s off the board. <button type="button" class="toast-action" data-undo-topic>Undo</button>`);
|
||||||
} else {
|
} else {
|
||||||
lastAction={prefs:JSON.parse(JSON.stringify(prefs)), hiddenCards:[...hiddenCards]};
|
lastAction={prefs:JSON.parse(JSON.stringify(prefs)), hiddenCards:[...hiddenCards]};
|
||||||
hiddenCards=hiddenCards.filter(x=>x!==id);
|
hiddenCards=hiddenCards.filter(x=>x!==id);
|
||||||
|
|||||||
Reference in New Issue
Block a user