forked from retoor/devplacepy
feat: replace raw setInterval polling with shared Poller utility across six frontend modules
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user