mirror of
https://github.com/flarum/framework.git
synced 2025-04-08 15:50:19 +08:00
Only load posts once when entering a discussion
This commit is contained in:
parent
e37d3743ed
commit
9938c346a1
@ -11,6 +11,8 @@ export default Ember.View.extend(Ember.Evented, {
|
|||||||
|
|
||||||
sidebarItems: null,
|
sidebarItems: null,
|
||||||
|
|
||||||
|
loadingNumber: false,
|
||||||
|
|
||||||
didInsertElement: function() {
|
didInsertElement: function() {
|
||||||
// Create and populate an array of items to be rendered in the sidebar.
|
// Create and populate an array of items to be rendered in the sidebar.
|
||||||
var sidebarItems = TaggedArray.create();
|
var sidebarItems = TaggedArray.create();
|
||||||
@ -28,20 +30,27 @@ export default Ember.View.extend(Ember.Evented, {
|
|||||||
// changes, we want to tell our stream content component to jump down
|
// changes, we want to tell our stream content component to jump down
|
||||||
// to it.
|
// to it.
|
||||||
this.get('controller').on('startWasChanged', this, this.goToNumber);
|
this.get('controller').on('startWasChanged', this, this.goToNumber);
|
||||||
|
this.get('streamContent').on('loadedNumber', this, this.loadedNumber);
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement: function() {
|
willDestroyElement: function() {
|
||||||
this.get('controller').off('startWasChanged', this, this.goToNumber);
|
this.get('controller').off('startWasChanged', this, this.goToNumber);
|
||||||
|
this.get('streamContent').off('loadedNumber', this, this.loadedNumber);
|
||||||
},
|
},
|
||||||
|
|
||||||
goToNumber: function(start) {
|
goToNumber: function(start) {
|
||||||
// We can only proceed if the controller has loaded the discussion
|
// We can only proceed if the controller has loaded the discussion
|
||||||
// details and the view has been rendered.
|
// details and the view has been rendered.
|
||||||
if (this.get('controller.loaded') && this.get('streamContent')) {
|
if (this.get('controller.loaded') && this.get('streamContent') && ! this.get('loadingNumber')) {
|
||||||
this.get('streamContent').send('goToNumber', start);
|
this.get('streamContent').send('goToNumber', start);
|
||||||
|
this.set('loadingNumber', true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
loadedNumber: function() {
|
||||||
|
this.set('loadingNumber', false);
|
||||||
|
},
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// OBSERVERS
|
// OBSERVERS
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user