diff --git a/src/main/webapp/app/shared/metis/posting.directive.ts b/src/main/webapp/app/shared/metis/posting.directive.ts index f62af4907e18..8464693e7874 100644 --- a/src/main/webapp/app/shared/metis/posting.directive.ts +++ b/src/main/webapp/app/shared/metis/posting.directive.ts @@ -42,6 +42,7 @@ export abstract class PostingDirective implements OnInit, OnD ngOnDestroy(): void { if (this.deleteTimer !== undefined) { clearTimeout(this.deleteTimer); + this.deletePostingWithoutTimeout(); } if (this.deleteInterval !== undefined) { @@ -65,11 +66,7 @@ export abstract class PostingDirective implements OnInit, OnD this.deleteTimer = setTimeout( () => { - if (this.isAnswerPost) { - this.metisService.deleteAnswerPost(this.posting); - } else { - this.metisService.deletePost(this.posting); - } + this.deletePostingWithoutTimeout(); }, // We add a tiny buffer to make it possible for the user to react a bit longer than the ui displays (+1000) this.deleteTimerInSeconds * 1000 + 1000, @@ -131,4 +128,12 @@ export abstract class PostingDirective implements OnInit, OnD this.posting.isSaved = true; } } + + private deletePostingWithoutTimeout() { + if (this.isAnswerPost) { + this.metisService.deleteAnswerPost(this.posting); + } else { + this.metisService.deletePost(this.posting); + } + } }