mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 04:11:11 +08:00
FIX: prevent multiple requests when clicking drafts trigger (#30736)
Adds a loading state to prevent multiple requests when clicking the drafts menu button. We are also making a very slight adjustment to button spacing (needed for both desktop and mobile).
This commit is contained in:
parent
dbc9fbfd8b
commit
33ea3599c2
@ -17,6 +17,7 @@ export default class TopicDraftsDropdown extends Component {
|
|||||||
@service composer;
|
@service composer;
|
||||||
|
|
||||||
@tracked drafts = [];
|
@tracked drafts = [];
|
||||||
|
@tracked loading = false;
|
||||||
|
|
||||||
get draftCount() {
|
get draftCount() {
|
||||||
return this.currentUser.draft_count;
|
return this.currentUser.draft_count;
|
||||||
@ -41,6 +42,8 @@ export default class TopicDraftsDropdown extends Component {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
async onShowMenu() {
|
async onShowMenu() {
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const draftsStream = this.currentUser.userDraftsStream;
|
const draftsStream = this.currentUser.userDraftsStream;
|
||||||
draftsStream.reset();
|
draftsStream.reset();
|
||||||
@ -50,6 +53,8 @@ export default class TopicDraftsDropdown extends Component {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error("Failed to fetch drafts with error:", error);
|
console.error("Failed to fetch drafts with error:", error);
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +82,7 @@ export default class TopicDraftsDropdown extends Component {
|
|||||||
@onShow={{this.onShowMenu}}
|
@onShow={{this.onShowMenu}}
|
||||||
@onRegisterApi={{this.onRegisterApi}}
|
@onRegisterApi={{this.onRegisterApi}}
|
||||||
@modalForMobile={{true}}
|
@modalForMobile={{true}}
|
||||||
|
@disabled={{this.loading}}
|
||||||
class="btn-small"
|
class="btn-small"
|
||||||
>
|
>
|
||||||
<:content>
|
<:content>
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
> * {
|
> * {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
&:not(:last-child) {
|
&:not(:last-child) {
|
||||||
margin-right: 0.5em;
|
margin-right: 0.4em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.select-kit-header {
|
.select-kit-header {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Styles for the drafts dropdown menu
|
// Styles for the drafts dropdown menu
|
||||||
|
|
||||||
.topic-drafts-menu-trigger {
|
.topic-drafts-menu-trigger {
|
||||||
margin-left: -0.4em;
|
margin-left: -0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.topic-drafts-menu-content {
|
.topic-drafts-menu-content {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user