diff --git a/src/lib/report_manager.tsx b/src/lib/report_manager.tsx index 57c7c6a6fd..d0ec5eba67 100644 --- a/src/lib/report_manager.tsx +++ b/src/lib/report_manager.tsx @@ -351,22 +351,31 @@ class ReportManager extends EventEmitter { this.updateIncidentReport(res); return res; } + public vote(report_id: number, voted_action: string, escalation_note: string): Promise { - const res = post(`moderation/incident/${report_id}`, { - action: "vote", // darn, yes, two different uses of the word "action" collide here + return post(`moderation/incident/${report_id}`, { + action: "vote", voted_action: voted_action, escalation_note: escalation_note, - }).then((res) => { - toast( -
- {pgettext("Thanking a community moderator for voting", "Submitted, thanks!")} -
, - 2000, - ); - this.updateIncidentReport(res); - return res; - }); - return res; + }) + .then((res) => { + toast( +
+ {pgettext( + "Thanking a community moderator for voting", + "Submitted, thanks!", + )} +
, + 2000, + ); + this.updateIncidentReport(res); + return res; + }) + .catch((error) => { + void alert.fire(`Error during vote submission: ${error.error}`); + console.error("Error during vote submission:", error); + throw error; + }); } public getHandledTodayCount(): number { diff --git a/src/views/ReportsCenter/ViewReport.tsx b/src/views/ReportsCenter/ViewReport.tsx index e4b6fddd2d..41b23f94a6 100644 --- a/src/views/ReportsCenter/ViewReport.tsx +++ b/src/views/ReportsCenter/ViewReport.tsx @@ -550,7 +550,7 @@ export function ViewReport({ report_id, reports, onChange }: ViewReportProps): J )} - {((!user.is_moderator && user.moderator_powers) || null) && ( + {!user.is_moderator && user.moderator_powers && (