Skip to content

Commit

Permalink
refactor composer load to use the composer instance internally
Browse files Browse the repository at this point in the history
  • Loading branch information
askvortsov1 committed Jun 19, 2020
1 parent 45eac47 commit 5ae0366
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions js/src/forum/components/IndexPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Dropdown from '../../common/components/Dropdown';
import Button from '../../common/components/Button';
import LinkButton from '../../common/components/LinkButton';
import SelectDropdown from '../../common/components/SelectDropdown';
import Composer from '../instances/Composer';

/**
* The `IndexPage` component displays the index page, including the welcome
Expand Down Expand Up @@ -274,7 +273,7 @@ export default class IndexPage extends Page {
const deferred = m.deferred();

if (app.session.user) {
app.composer.load(new Composer(DiscussionComposer, { user: app.session.user }));
app.composer.load(DiscussionComposer, { user: app.session.user });
app.composer.show();

deferred.resolve(app.composer);
Expand Down
6 changes: 4 additions & 2 deletions js/src/forum/states/ComposerState.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ class ComposerState {
/**
* Load a content component into the composer.
*
* @param {Composer} composer
* @param {ComposerBody} bodyClass
* @public
*/
load(body) {
load(bodyClass, bodyAttrs) {
const body = new Composer(bodyClass, bodyAttrs);

if (this.preventExit()) return;

// If we load a similar component into the composer, then Mithril will be
Expand Down
10 changes: 4 additions & 6 deletions js/src/forum/utils/DiscussionControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,10 @@ export default {
if (app.session.user) {
if (this.canReply()) {
if (!app.composer.composingReplyTo(this) || forceRefresh) {
app.composer.load(
new Composer(ReplyComposer, {
user: app.session.user,
discussion: this,
})
);
app.composer.load(ReplyComposer, {
user: app.session.user,
discussion: this,
});
}
app.composer.show();

Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/utils/PostControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default {
editAction() {
const deferred = m.deferred();

app.composer.load(new Composer(EditPostComposer, { post: this }));
app.composer.load(EditPostComposer, { post: this });
app.composer.show();

deferred.resolve(app.composer);
Expand Down

0 comments on commit 5ae0366

Please sign in to comment.