mirror of
https://github.com/flarum/core.git
synced 2025-07-29 12:40:40 +02:00
Rename/fix post stream
This commit is contained in:
@@ -118,7 +118,7 @@ export default Ember.Component.extend({
|
|||||||
// Tell the controller that we want to load the range of posts that this
|
// Tell the controller that we want to load the range of posts that this
|
||||||
// gap represents. We also specify which direction we want to load the
|
// gap represents. We also specify which direction we want to load the
|
||||||
// posts from.
|
// posts from.
|
||||||
this.get('controller').send(
|
this.sendAction(
|
||||||
'loadRange',
|
'loadRange',
|
||||||
this.get('start') + (relativeIndex || 0),
|
this.get('start') + (relativeIndex || 0),
|
||||||
this.get('end'),
|
this.get('end'),
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
|
|
||||||
import PostStream from '../models/post-stream';
|
import Stream from '../models/stream';
|
||||||
|
|
||||||
export default Ember.ObjectController.extend(Ember.Evented, {
|
export default Ember.ObjectController.extend(Ember.Evented, {
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ export default Ember.ObjectController.extend(Ember.Evented, {
|
|||||||
searchQuery: '',
|
searchQuery: '',
|
||||||
|
|
||||||
loaded: false,
|
loaded: false,
|
||||||
postStream: null,
|
stream: null,
|
||||||
|
|
||||||
setup: function(discussion) {
|
setup: function(discussion) {
|
||||||
this.set('model', discussion);
|
this.set('model', discussion);
|
||||||
@@ -19,10 +19,10 @@ export default Ember.ObjectController.extend(Ember.Evented, {
|
|||||||
// Set up the post stream object. It needs to know about the discussion
|
// Set up the post stream object. It needs to know about the discussion
|
||||||
// its representing the posts for, and we also need to inject the Ember
|
// its representing the posts for, and we also need to inject the Ember
|
||||||
// data store.
|
// data store.
|
||||||
var postStream = PostStream.create();
|
var stream = Stream.create();
|
||||||
postStream.set('discussion', discussion);
|
stream.set('discussion', discussion);
|
||||||
postStream.set('store', this.get('store'));
|
stream.set('store', this.get('store'));
|
||||||
this.set('postStream', postStream);
|
this.set('stream', stream);
|
||||||
|
|
||||||
// Next, we need to load a list of the discussion's post IDs into the
|
// Next, we need to load a list of the discussion's post IDs into the
|
||||||
// post stream object. If we don't already have this information, we'll
|
// post stream object. If we don't already have this information, we'll
|
||||||
@@ -33,7 +33,7 @@ export default Ember.ObjectController.extend(Ember.Evented, {
|
|||||||
// them. Then we're ready to load some posts!
|
// them. Then we're ready to load some posts!
|
||||||
var controller = this;
|
var controller = this;
|
||||||
promise.then(function(discussion) {
|
promise.then(function(discussion) {
|
||||||
postStream.setup(discussion.get('postIds'));
|
stream.setup(discussion.get('postIds'));
|
||||||
controller.set('loaded', true);
|
controller.set('loaded', true);
|
||||||
controller.send('jumpToNumber', controller.get('start'));
|
controller.send('jumpToNumber', controller.get('start'));
|
||||||
});
|
});
|
||||||
@@ -71,7 +71,7 @@ export default Ember.ObjectController.extend(Ember.Evented, {
|
|||||||
// position are loaded. We will tell our listeners when they are.
|
// position are loaded. We will tell our listeners when they are.
|
||||||
// Again, the view will scroll down to the appropriate post.
|
// Again, the view will scroll down to the appropriate post.
|
||||||
var controller = this;
|
var controller = this;
|
||||||
this.get('postStream').loadNearNumber(number).then(function() {
|
this.get('stream').loadNearNumber(number).then(function() {
|
||||||
Ember.run.scheduleOnce('afterRender', function() {
|
Ember.run.scheduleOnce('afterRender', function() {
|
||||||
controller.trigger('loadedNumber', number);
|
controller.trigger('loadedNumber', number);
|
||||||
});
|
});
|
||||||
@@ -89,7 +89,7 @@ export default Ember.ObjectController.extend(Ember.Evented, {
|
|||||||
// loaded. We will tell our listeners when they are. Again, the view
|
// loaded. We will tell our listeners when they are. Again, the view
|
||||||
// will scroll down to the appropriate post.
|
// will scroll down to the appropriate post.
|
||||||
var controller = this;
|
var controller = this;
|
||||||
this.get('postStream').loadNearIndex(index).then(function() {
|
this.get('stream').loadNearIndex(index).then(function() {
|
||||||
Ember.run.scheduleOnce('afterRender', function() {
|
Ember.run.scheduleOnce('afterRender', function() {
|
||||||
controller.trigger('loadedIndex', index);
|
controller.trigger('loadedIndex', index);
|
||||||
});
|
});
|
||||||
@@ -97,7 +97,7 @@ export default Ember.ObjectController.extend(Ember.Evented, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
loadRange: function(start, end, backwards) {
|
loadRange: function(start, end, backwards) {
|
||||||
this.get('postStream').loadRange(start, end, backwards);
|
this.get('stream').loadRange(start, end, backwards);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
import Ember from 'ember';
|
|
||||||
|
|
||||||
// Represents a collection of results (e.g. a list of discussions)
|
|
||||||
|
|
||||||
export default Ember.Object.extend({
|
|
||||||
|
|
||||||
// An array of the results.
|
|
||||||
results: Em.A(),
|
|
||||||
|
|
||||||
// The currently-active result.
|
|
||||||
currentResult: null,
|
|
||||||
|
|
||||||
sort: null,
|
|
||||||
|
|
||||||
// The index of the currently-active result (determined by ID.) Returns '?'
|
|
||||||
// if the currently-active result is not in the results list.
|
|
||||||
index: function() {
|
|
||||||
var index = '?';
|
|
||||||
var id = this.get('currentResult.id');
|
|
||||||
this.get('results').some(function(result, i) {
|
|
||||||
if (result.get('id') == id) {
|
|
||||||
index = i + 1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return index;
|
|
||||||
}.property('currentResult', 'results'),
|
|
||||||
|
|
||||||
// The number of results.
|
|
||||||
count: function() {
|
|
||||||
return this.get('results.length');
|
|
||||||
}.property('results'),
|
|
||||||
|
|
||||||
// The previous result.
|
|
||||||
previous: function() {
|
|
||||||
return this.get('results').objectAt(this.get('index') - 2);
|
|
||||||
}.property('index'),
|
|
||||||
|
|
||||||
// The next result.
|
|
||||||
next: function() {
|
|
||||||
return this.get('results').objectAt(this.get('index'));
|
|
||||||
}.property('index'),
|
|
||||||
|
|
||||||
});
|
|
@@ -1 +1 @@
|
|||||||
{{loading-indicator size="large"}}
|
{{ui/controls/loading-indicator size="large"}}
|
||||||
|
Reference in New Issue
Block a user