diff --git a/src/main/webapp/app/shared/metis/posting.directive.ts b/src/main/webapp/app/shared/metis/posting.directive.ts index 71c40bf0b12e..2283008c18b3 100644 --- a/src/main/webapp/app/shared/metis/posting.directive.ts +++ b/src/main/webapp/app/shared/metis/posting.directive.ts @@ -49,6 +49,7 @@ export abstract class PostingDirective implements OnInit, OnD ngOnDestroy(): void { if (this.deleteTimer !== undefined) { clearTimeout(this.deleteTimer); + this.deletePostingWithoutTimeout(); } if (this.deleteInterval !== undefined) { @@ -72,11 +73,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, @@ -139,6 +136,11 @@ export abstract class PostingDirective implements OnInit, OnD } } + private deletePostingWithoutTimeout() { + if (this.isAnswerPost) { + this.metisService.deleteAnswerPost(this.posting); + } else { + this.metisService.deletePost(this.posting); /** * Create a or navigate to one-to-one chat with the referenced user *