diff --git a/frontend/src/app/pages/forms/discord-appeal/discord-appeal.component.ts b/frontend/src/app/pages/forms/discord-appeal/discord-appeal.component.ts index 172f116..d85676a 100644 --- a/frontend/src/app/pages/forms/discord-appeal/discord-appeal.component.ts +++ b/frontend/src/app/pages/forms/discord-appeal/discord-appeal.component.ts @@ -13,6 +13,7 @@ import {MatIconModule} from '@angular/material/icon'; import {VerifyMailDialogComponent} from '@pages/forms/verify-mail-dialog/verify-mail-dialog.component'; import {MatDialog} from '@angular/material/dialog'; import {Router} from '@angular/router'; +import {finalize} from 'rxjs'; @Component({ selector: 'app-discord-appeal', @@ -131,7 +132,12 @@ export class DiscordAppealComponent implements OnInit { return this.currentPageIndex === this.totalPages.length - 1; } + private punishmentLoading: boolean = false; + protected checkPunishment() { + if (this.punishmentLoading) { + return; + } if (window.location.hostname === 'localhost') { this.bannedUser = { isBanned: false, @@ -146,6 +152,9 @@ export class DiscordAppealComponent implements OnInit { return } this.appealService.getBannedUser(this.discordId) + .pipe( + finalize(() => this.punishmentLoading = false) + ) .subscribe(user => { this.bannedUser = user this.nextPage(); @@ -171,7 +180,12 @@ export class DiscordAppealComponent implements OnInit { } } + private formSubmitting: boolean = false; + private sendForm() { + if (this.formSubmitting) { + return; + } const rawValue = this.form.getRawValue(); const uuid = this.authService.getUuid(); if (uuid === null) { @@ -182,14 +196,18 @@ export class DiscordAppealComponent implements OnInit { appeal: rawValue.appeal, email: rawValue.email, } - this.appealService.submitDiscordAppeal(appeal).subscribe((result) => { - if (!result.verified_mail) { - throw new Error('Mail not verified'); - } - this.router.navigate(['/forms/sent'], { - state: {message: result.message} - }).then(); - }) + this.appealService.submitDiscordAppeal(appeal) + .pipe( + finalize(() => this.formSubmitting = false) + ) + .subscribe((result) => { + if (!result.verified_mail) { + throw new Error('Mail not verified'); + } + this.router.navigate(['/forms/sent'], { + state: {message: result.message} + }).then(); + }) } }