mirror of
https://github.com/flarum/framework.git
synced 2024-12-04 08:13:39 +08:00
Refresh discussion after logging in. Fixes #68
This commit is contained in:
parent
a7ff92cbff
commit
b11595de06
|
@ -21,7 +21,7 @@ export default class DiscussionList extends Component {
|
||||||
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
|
||||||
app.session.on('loggedIn', this.loggedInHandler = this.refresh.bind(this))
|
app.session.on('loggedIn', this.loggedInHandler = this.refresh.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
params() {
|
params() {
|
||||||
|
|
|
@ -31,10 +31,7 @@ export default class DiscussionPage extends Component {
|
||||||
// its posts relationship has been loaded (i.e. we've viewed this
|
// its posts relationship has been loaded (i.e. we've viewed this
|
||||||
// discussion before), then we can proceed with displaying it immediately.
|
// discussion before), then we can proceed with displaying it immediately.
|
||||||
// If not, we'll make an API request first.
|
// If not, we'll make an API request first.
|
||||||
this.currentNear = m.route.param('near') || 0;
|
this.refresh();
|
||||||
var params = this.params();
|
|
||||||
params.include = params.include.join(',');
|
|
||||||
app.store.find('discussions', m.route.param('id'), params).then(this.setupDiscussion.bind(this));
|
|
||||||
|
|
||||||
if (app.cache.discussionList) {
|
if (app.cache.discussionList) {
|
||||||
if (!(app.current instanceof DiscussionPage)) {
|
if (!(app.current instanceof DiscussionPage)) {
|
||||||
|
@ -47,6 +44,18 @@ export default class DiscussionPage extends Component {
|
||||||
|
|
||||||
app.history.push('discussion');
|
app.history.push('discussion');
|
||||||
app.current = this;
|
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() {
|
params() {
|
||||||
|
@ -127,6 +136,7 @@ export default class DiscussionPage extends Component {
|
||||||
|
|
||||||
app.pane.disable();
|
app.pane.disable();
|
||||||
app.composer.minimize();
|
app.composer.minimize();
|
||||||
|
app.session.off('loggedIn', this.loggedInHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default function(app) {
|
||||||
} else if (!app.session.user()) {
|
} else if (!app.session.user()) {
|
||||||
app.modal.show(new LoginModal({
|
app.modal.show(new LoginModal({
|
||||||
message: 'You must be logged in to do that.',
|
message: 'You must be logged in to do that.',
|
||||||
callback: replyAction.bind(this)
|
callback: this.replyAction.bind(this)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user