This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/mixins/open-composer.js.es6
Joffrey JAFFEUX b1593c0184
FIX: prevents exception when opening new topic on mobile
Repro:

- Visit https://meta.discourse.org/categories, refresh the page
- Navigate to Latest
- Click New Topic
- Error occurs
2018-02-06 14:48:04 +01:00

40 lines
1.1 KiB
JavaScript

// This mixin allows a route to open the composer
import Composer from 'discourse/models/composer';
export default Ember.Mixin.create({
openComposer(controller) {
this.controllerFor('composer').open({
categoryId: controller.get('category.id'),
action: Composer.CREATE_TOPIC,
draftKey: controller.get('model.draft_key') || Composer.CREATE_TOPIC,
draftSequence: controller.get('model.draft_sequence') || 0
});
},
openComposerWithTopicParams(controller, topicTitle, topicBody, topicCategoryId, topicCategory, topicTags) {
this.controllerFor('composer').open({
action: Composer.CREATE_TOPIC,
topicTitle,
topicBody,
topicCategoryId,
topicCategory,
topicTags,
draftKey: controller.get('model.draft_key'),
draftSequence: controller.get('model.draft_sequence')
});
},
openComposerWithMessageParams(usernames, topicTitle, topicBody) {
this.controllerFor('composer').open({
action: Composer.PRIVATE_MESSAGE,
usernames,
topicTitle,
topicBody,
archetypeId: 'private_message',
draftKey: Composer.NEW_PRIVATE_MESSAGE_KEY
});
}
});