Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tell CMs if their vote errors on the back end #2852

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions src/lib/report_manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,22 +351,31 @@ class ReportManager extends EventEmitter<Events> {
this.updateIncidentReport(res);
return res;
}

public vote(report_id: number, voted_action: string, escalation_note: string): Promise<Report> {
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(
<div>
{pgettext("Thanking a community moderator for voting", "Submitted, thanks!")}
</div>,
2000,
);
this.updateIncidentReport(res);
return res;
});
return res;
})
.then((res) => {
toast(
<div>
{pgettext(
"Thanking a community moderator for voting",
"Submitted, thanks!",
)}
</div>,
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 {
Expand Down
3 changes: 1 addition & 2 deletions src/views/ReportsCenter/ViewReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ export function ViewReport({ report_id, reports, onChange }: ViewReportProps): J
</div>
)}

{((!user.is_moderator && user.moderator_powers) || null) && (
{!user.is_moderator && user.moderator_powers && (
<div className="voting">
<ModerationActionSelector
available_actions={availableActions ?? []}
Expand All @@ -568,7 +568,6 @@ export function ViewReport({ report_id, reports, onChange }: ViewReportProps): J
(!report.escalated ||
!!(user.moderator_powers & MODERATOR_POWERS.SUSPEND))
}
// clear the selection for subsequent reports
key={report.id}
report={report}
/>
Expand Down
Loading