Refresh discussion after logging in. Fixes #68

This commit is contained in:
Toby Zerner 2015-05-18 15:07:04 +09:30
parent a7ff92cbff
commit b11595de06
3 changed files with 16 additions and 6 deletions

View File

@ -21,7 +21,7 @@ export default class DiscussionList extends Component {
this.refresh();
app.session.on('loggedIn', this.loggedInHandler = this.refresh.bind(this))
app.session.on('loggedIn', this.loggedInHandler = this.refresh.bind(this));
}
params() {

View File

@ -31,10 +31,7 @@ export default class DiscussionPage extends Component {
// its posts relationship has been loaded (i.e. we've viewed this
// discussion before), then we can proceed with displaying it immediately.
// If not, we'll make an API request first.
this.currentNear = m.route.param('near') || 0;
var params = this.params();
params.include = params.include.join(',');
app.store.find('discussions', m.route.param('id'), params).then(this.setupDiscussion.bind(this));
this.refresh();
if (app.cache.discussionList) {
if (!(app.current instanceof DiscussionPage)) {
@ -47,6 +44,18 @@ export default class DiscussionPage extends Component {
app.history.push('discussion');
app.current = this;
app.session.on('loggedIn', this.loggedInHandler = this.refresh.bind(this));
}
refresh() {
this.currentNear = m.route.param('near') || 0;
this.discussion(null);
var params = this.params();
params.include = params.include.join(',');
app.store.find('discussions', m.route.param('id'), params).then(this.setupDiscussion.bind(this));
m.redraw();
}
params() {
@ -127,6 +136,7 @@ export default class DiscussionPage extends Component {
app.pane.disable();
app.composer.minimize();
app.session.off('loggedIn', this.loggedInHandler);
}
/**

View File

@ -25,7 +25,7 @@ export default function(app) {
} else if (!app.session.user()) {
app.modal.show(new LoginModal({
message: 'You must be logged in to do that.',
callback: replyAction.bind(this)
callback: this.replyAction.bind(this)
}));
}
}