mirror of
https://github.com/discourse/discourse.git
synced 2025-01-28 03:34:00 +08:00
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
export default Ember.ArrayProxy.extend({
|
|
loading: false,
|
|
loadingMore: false,
|
|
totalRows: 0,
|
|
refreshing: false,
|
|
|
|
content: null,
|
|
loadMoreUrl: null,
|
|
refreshUrl: null,
|
|
findArgs: null,
|
|
store: null,
|
|
__type: null,
|
|
|
|
canLoadMore: function() {
|
|
return this.get('length') < this.get('totalRows');
|
|
}.property('totalRows', 'length'),
|
|
|
|
loadMore() {
|
|
const loadMoreUrl = this.get('loadMoreUrl');
|
|
if (!loadMoreUrl) { return; }
|
|
|
|
const totalRows = this.get('totalRows');
|
|
if (this.get('length') < totalRows && !this.get('loadingMore')) {
|
|
this.set('loadingMore', true);
|
|
|
|
const self = this;
|
|
return this.store.appendResults(this, this.get('__type'), loadMoreUrl).finally(function() {
|
|
self.set('loadingMore', false);
|
|
});
|
|
}
|
|
|
|
return Ember.RSVP.resolve();
|
|
},
|
|
|
|
refresh() {
|
|
if (this.get('refreshing')) { return; }
|
|
|
|
const refreshUrl = this.get('refreshUrl');
|
|
if (!refreshUrl) { return; }
|
|
|
|
const self = this;
|
|
this.set('refreshing', true);
|
|
return this.store.refreshResults(this, this.get('__type'), refreshUrl).finally(function() {
|
|
self.set('refreshing', false);
|
|
});
|
|
|
|
}
|
|
});
|