-
Notifications
You must be signed in to change notification settings - Fork 297
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
Communication
: Change posting deletion logic to not abort when deconstructing a post
#10073
base: develop
Are you sure you want to change the base?
Communication
: Change posting deletion logic to not abort when deconstructing a post
#10073
Conversation
…ion-when-deconstructing-post
WalkthroughThe pull request introduces a new private method Changes
Suggested labels
Suggested reviewers
Possibly related PRs
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Communication
: Change posting deletion logic to not abort when deconstructing a post
|
…ion-when-deconstructing-post
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/main/webapp/app/shared/metis/posting.directive.ts (2)
139-145
: Consider enhancing error handling and state management.While the method successfully consolidates the deletion logic, consider these improvements for better robustness:
- Add error handling for service calls
- Clean up local state after successful deletion
- Handle subscription lifecycle
Consider this enhanced implementation:
private deletePostingWithoutTimeout() { + const deleteOperation = this.isAnswerPost + ? this.metisService.deleteAnswerPost(this.posting) + : this.metisService.deletePost(this.posting); + + deleteOperation.subscribe({ + next: () => { + // Clean up local state + this.content = undefined; + this.isDeleted = true; + }, + error: (error) => { + console.error('Failed to delete posting:', error); + this.isDeleted = false; + } + }).add(() => { + // Ensure timers are cleared + if (this.deleteTimer) { + clearTimeout(this.deleteTimer); + this.deleteTimer = undefined; + } + if (this.deleteInterval) { + clearInterval(this.deleteInterval); + this.deleteInterval = undefined; + } + }); - if (this.isAnswerPost) { - this.metisService.deleteAnswerPost(this.posting); - } else { - this.metisService.deletePost(this.posting); - } }
139-139
: Add JSDoc documentation for the new method.Following Angular style guide best practices, consider adding JSDoc documentation to describe the method's purpose and behavior.
Add documentation above the method:
+ /** + * Immediately deletes the posting without waiting for the deletion timeout. + * This is called when the directive is destroyed or when the deletion timer expires. + * @private + */ private deletePostingWithoutTimeout() {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/webapp/app/shared/metis/posting.directive.ts
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/app/shared/metis/posting.directive.ts (1)
🔇 Additional comments (2)
src/main/webapp/app/shared/metis/posting.directive.ts (2)
52-52
: LGTM! Ensures deletion completion during directive destruction.
The change properly handles the deletion operation when the directive is destroyed, preventing unintended abortion of the deletion process.
76-76
: LGTM! Improves code maintainability.
The change centralizes the deletion logic by using the new deletePostingWithoutTimeout
method while preserving the existing timer behavior.
…ion-when-deconstructing-post
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on TS3. Works as described
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on TS4, everything works as intended
Checklist
General
Client
authorities
to all new routes and checked the course groups for displaying navigation elements (links, buttons).Motivation and Context
Proposed by: #9848
Currently when one deletes a message and switches the chat or generally leaves the communication area before the deletion countdown has expired the delete operation gets aborted. In my opinion this should not be the intended behaviour as I as a user expect a message to get deleted when I press the delete button and leave the page.
Description
When the posting gets deconstructed the client now stops the delete timeout and instantly deletes the posting as it would have once the timeout expired
Steps for Testing
Prerequisites:
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Review Progress
Performance Review
Code Review
Manual Tests
Exam Mode Test
Performance Tests
Screenshots
Summary by CodeRabbit
Summary by CodeRabbit
Bug Fixes
Refactor