feat: replace raw setInterval polling with shared Poller utility across six frontend modules

This commit is contained in:
2026-06-09 16:37:49 +00:00
parent 1ec011ecb2
commit 66dfda88bc
27 changed files with 282 additions and 350 deletions
+5 -11
View File
@@ -1,8 +1,8 @@
import { Toast } from "./Toast.js";
import { Http } from "./Http.js";
import { OptimisticAction } from "./OptimisticAction.js";
export class VoteManager {
export class VoteManager extends OptimisticAction {
constructor() {
super();
this.initVoteButtons();
}
@@ -17,16 +17,10 @@ export class VoteManager {
});
}
async cast(form, button) {
cast(form, button) {
const action = form.getAttribute("action");
const value = form.querySelector('input[name="value"]').value;
try {
const result = await Http.sendForm(action, { value });
this.render(action, result);
} catch (error) {
console.error("vote failed", error);
Toast.flash(button, "Error", 1500);
}
return this.submit(action, { value }, button, (result) => this.render(action, result));
}
render(action, result) {