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

FIX: Hide timer info on topic status toggle #25596

Conversation

turtlestackdev
Copy link
Contributor

Fix for https://meta.discourse.org/t/minor-ui-bug-with-manually-closing-a-topic-that-has-a-topic-timer-set-for-auto-close-in-the-future/289482

When an auto close/open timer is set and the user manually opens/closes the topic, the timer info remains displayed until the page is refreshed.

The changes here fix that by adding a @statusUpdate property to the timer info within the topic template.

The @statusUpdate property is read in the topic-timer-info component. When this value is defined, and the timer statusType matches the the topic status, the timer info showTopicTimer and executedAt values are set to null. The latter is modified to prevent the info from being incorrectly displayed if the user toggles the status back to open.

The @statusUpdate property is set to the value of the topic topic_status_update which is undefined by default. After the topic controller toggleClosed function finishes, this value is updated with the return value from the API. This in turn triggers another render of the topic-timer-info component which now has the information it needs to hide itself.

This does trigger an additional render of the timer info after the hooks are fired, but I felt it was acceptable.

Three acceptance tests have been added to topic-edit-timer-test.js.

  • auto-close timer is hidden after manually closing the topic
  • auto-open timer is hidden after manually opening the topic
  • auto-close timer is hidden after manually closing and then re-opening the topic

The topic test fixture needed a minor adjustment to enable toggling the topic status.

Use topic.topic_status_update value to hide timer info after status
change.
@discoursebot
Copy link

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/minor-ui-bug-with-manually-closing-a-topic-that-has-a-topic-timer-set-for-auto-close-in-the-future/289482/6

Copy link
Contributor

@janzenisaac janzenisaac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks great @turtlestackdev. I appreciate the comments and tests for clarity. Nice work, thank you! :)

@pmusaraj pmusaraj merged commit 53a198a into discourse:main Feb 14, 2024
18 checks passed
@turtlestackdev turtlestackdev deleted the fix/topic_timer_visible_after_status_toggle branch February 14, 2024 16:47
renato pushed a commit to renato/discourse that referenced this pull request Feb 29, 2024
Use topic.topic_status_update value to hide timer info after status
change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants