DEV: Rely on route action to open composer. (#17118)

Avoid duplicating composer logic in multiple places.
This commit is contained in:
Alan Guo Xiang Tan 2022-06-20 10:06:15 +08:00 committed by GitHub
parent 78fab9b7e1
commit 222a7755a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 14 deletions

View File

@ -1,9 +1,6 @@
import { action } from "@ember/object";
import { cached } from "@glimmer/tracking";
import GlimmerComponent from "discourse/components/glimmer";
import Composer from "discourse/models/composer";
import { getOwner } from "discourse-common/lib/get-owner";
import GroupMessageSectionLink from "discourse/lib/sidebar/messages-section/group-message-section-link";
import PersonalMessageSectionLink from "discourse/lib/sidebar/messages-section/personal-message-section-link";
@ -90,14 +87,4 @@ export default class SidebarMessagesSection extends GlimmerComponent {
return links;
}
@action
composePersonalMessage() {
const composerArgs = {
action: Composer.PRIVATE_MESSAGE,
draftKey: Composer.NEW_TOPIC_KEY,
};
getOwner(this).lookup("controller:composer").open(composerArgs);
}
}

View File

@ -2,7 +2,7 @@
@sectionName="messages"
@headerRoute="userPrivateMessages.index"
@headerModel={{this.currentUser}}
@headerAction={{this.composePersonalMessage}}
@headerAction={{fn (route-action "composePrivateMessage") null null}}
@headerActionIcon="plus"
@headerLinkText={{i18n "sidebar.sections.messages.header_link_text"}}
@headerLinkTitle={{i18n "sidebar.sections.messages.header_link_title"}} >