Skip to content

A platform for community discussion. Free, open, simple.

FIX: Disable replies button until replies are loaded (#35136)

Tethys Plex43fa61b363d4
diff --git a/app/assets/javascripts/discourse/app/components/post.gjs b/app/assets/javascripts/discourse/app/components/post.gjs
index 55490812b26..355b171200b 100644
--- a/app/assets/javascripts/discourse/app/components/post.gjs
+++ b/app/assets/javascripts/discourse/app/components/post.gjs
@@ -51,6 +51,11 @@ export default class Post extends Component {
@tracked repliesAbove;
@tracked repliesBelow = new TrackedArray();
+ /**
+ * @type {boolean}
+ */
+ @tracked isTogglingReplies = false;
+
decoratorState = new TrackedMap();
addEventListeners = modifier((element, [listeners]) => {
@@ -316,9 +321,19 @@ export default class Post extends Component {
@action
async toggleReplies() {
- return this.filteredRepliesView
- ? await this.toggleFilteredRepliesView()
- : await this.toggleRepliesBelow();
+ if (this.isTogglingReplies) {
+ return;
+ }
+
+ this.isTogglingReplies = true;
+
+ try {
+ return this.filteredRepliesView
+ ? await this.toggleFilteredRepliesView()
+ : await this.toggleRepliesBelow();
+ } finally {
+ this.isTogglingReplies = false;
+ }
}
@action
@@ -585,6 +600,7 @@ export default class Post extends Component {
@rebakePost={{@rebakePost}}
@recoverPost={{@recoverPost}}
@repliesShown={{this.repliesShown}}
+ @repliesButtonDisabled={{this.isTogglingReplies}}
@replyToPost={{@replyToPost}}
@share={{this.share}}
@showFlags={{@showFlags}}
diff --git a/app/assets/javascripts/discourse/app/components/post/menu.gjs b/app/assets/javascripts/discourse/app/components/post/menu.gjs
index 125eac2f844..9d34e2b84a6 100644
--- a/app/assets/javascripts/discourse/app/components/post/menu.gjs
+++ b/app/assets/javascripts/discourse/app/components/post/menu.gjs
@@ -598,6 +598,7 @@ export default class PostMenu extends Component {
isWhoReadVisible: this.isWhoReadVisible,
isWikiMode: this.isWikiMode,
repliesShown: this.args.repliesShown,
+ repliesButtonDisabled: this.args.repliesButtonDisabled,
replyDirectlyBelow:
this.args.nextPost?.reply_to_post_number ===
this.args.post.post_number &&
diff --git a/app/assets/javascripts/discourse/app/components/post/menu/buttons/replies.gjs b/app/assets/javascripts/discourse/app/components/post/menu/buttons/replies.gjs
index 516e5c0a488..c63f3eea631 100644
--- a/app/assets/javascripts/discourse/app/components/post/menu/buttons/replies.gjs
+++ b/app/assets/javascripts/discourse/app/components/post/menu/buttons/replies.gjs
@@ -26,7 +26,7 @@ export default class PostMenuRepliesButton extends Component {
@service site;
get disabled() {
- return !!this.args.post.deleted;
+ return !!this.args.post.deleted || this.args.state?.repliesButtonDisabled;
}
get translatedTitle() {