Antispam: "Mark as not spam" must survive having marked it as spam
In the spam folder the menu showed a disabled "Marked as spam" for any message the user had marked, hiding the one action that corrects the mistake. The already-taught check ran before the folder check, so it suppressed both directions rather than the one already taken. The folder now decides what is on offer first, and only the lesson already taught is suppressed — never its opposite. A message in the spam folder always offers "Mark as not spam", whatever it was taught. Reported from the running app: "Klaudia, czy wpisujemy Cię na listę obecnych?" (folder=junk, learned=spam) showed the disabled state, while two provider-filed messages beside it with no verdict row behaved correctly. Adds a vitest for the bundle's decision table. It is small but has now been wrong twice, and the mount contract makes these bundles directly drivable. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018SqJYt7jD7oUEkoY68sBZo
This commit is contained in:
@@ -25,18 +25,21 @@ export default function mount(el, ctx, props) {
|
||||
}
|
||||
if (disposed || !data) return;
|
||||
|
||||
// Already taught: show it, greyed, rather than offering the same lesson.
|
||||
// The folder decides which action is on offer — FIRST. A message sitting in
|
||||
// the spam folder offers "not spam" no matter what it was taught, because
|
||||
// that is exactly the message someone needs to correct.
|
||||
const action = MEANINGFUL[data.special_use];
|
||||
if (!action) return;
|
||||
|
||||
// Only suppress the lesson we already taught, never its opposite.
|
||||
const learned = data.verdict && data.verdict.learned;
|
||||
if (learned) {
|
||||
if (learned === action.verdict) {
|
||||
el.innerHTML = `<button class="wm-menu-item" disabled>${
|
||||
learned === "spam" ? "Marked as spam" : "Marked as not spam"
|
||||
}</button>`;
|
||||
return;
|
||||
}
|
||||
|
||||
const action = MEANINGFUL[data.special_use];
|
||||
if (!action) return;
|
||||
|
||||
el.innerHTML = `<button class="wm-menu-item">${action.label}</button>`;
|
||||
el.querySelector("button").addEventListener("click", async () => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user