Skip to content
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
22 changes: 18 additions & 4 deletions components/PlayerSanctions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1013,10 +1013,13 @@ export default {
if (!this.sanctionToDelete) {
return;
}
// Held locally: the dialog closes on confirm, so another removal can
// replace sanctionToDelete while this one waits on the server.
const sanction = this.sanctionToDelete;
this.removingSanction = true;

try {
await (this as any).$apollo.mutate({
const { data } = await (this as any).$apollo.mutate({
mutation: gql`
mutation UnsanctionServerPlayer(
$serverId: String
Expand All @@ -1038,16 +1041,27 @@ export default {
variables: {
serverId: this.serverId ?? null,
steam_id: this.playerId,
type: this.sanctionToDelete.type,
sanction_id: this.sanctionToDelete.id,
type: sanction.type,
sanction_id: sanction.id,
},
});

const result = data?.unsanctionServerPlayer;

toast({
title: this.$t("player.sanctions.removed"),
description:
this.serverId &&
sanction.type !== "warning" &&
result &&
!result.enforced
? result.message
: undefined,
});

this.sanctionToDelete = null;
if (this.sanctionToDelete === sanction) {
this.sanctionToDelete = null;
}
} catch (error) {
console.error("Failed to remove sanction:", error);
toast({
Expand Down
17 changes: 9 additions & 8 deletions components/SanctionPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,6 @@ import SettingHeader from "~/components/match/SettingHeader.vue";
<p v-if="isWarning" class="text-sm text-muted-foreground">
{{ $t("player.sanction.warning_note") }}
</p>
<div
v-else-if="serverId && sanctionType && sanctionType !== 'ban'"
class="flex gap-2 items-start text-sm text-[hsl(var(--tac-amber))]"
>
<TriangleAlert class="mt-0.5 h-4 w-4 shrink-0" />
{{ $t("pages.dedicated_servers.detail.sanctions_wip") }}
</div>

<Separator class="my-2" />
</DrawerHeader>
Expand Down Expand Up @@ -329,7 +322,7 @@ export default {

this.submitting = true;
try {
await this.$apollo.mutate({
const { data } = await this.$apollo.mutate({
mutation: gql`
mutation SanctionServerPlayer(
$serverId: String
Expand Down Expand Up @@ -363,10 +356,18 @@ export default {
},
});

const result = data?.sanctionServerPlayer;

// Saved either way; the message says why it could not reach the
// server live, e.g. a community server without the plugin.
toast({
title: this.$t(`player.sanction.applied.${this.sanctionType}`, {
name: this.player.name,
}),
description:
this.serverId && !this.isWarning && result && !result.enforced
? result.message
: undefined,
});

this.sanctioningPlayer = false;
Expand Down
Loading
Loading