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

Development: Change posting deletion logic to not abort when deconstructing a post #10073

Merged
Changes from 4 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
15 changes: 10 additions & 5 deletions src/main/webapp/app/shared/metis/posting.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export abstract class PostingDirective<T extends Posting> implements OnInit, OnD
ngOnDestroy(): void {
if (this.deleteTimer !== undefined) {
clearTimeout(this.deleteTimer);
this.deletePostingWithoutTimeout();
}

if (this.deleteInterval !== undefined) {
Expand All @@ -72,11 +73,7 @@ export abstract class PostingDirective<T extends Posting> 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,
Expand Down Expand Up @@ -139,6 +136,14 @@ export abstract class PostingDirective<T extends Posting> 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
*
Expand Down
Loading