[deprecations] Use regular computed property instead of arrayComputed
This commit is contained in:
parent
03332a8654
commit
f5823669b2
|
@ -1,5 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
import limit from 'travis/utils/computed-limit';
|
||||
import Repo from 'travis/models/repo';
|
||||
import Config from 'travis/config/environment';
|
||||
|
||||
|
|
|
@ -1,30 +1,12 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
var limit = function(dependentKey, limitKey) {
|
||||
var options = {
|
||||
addedItem: function(array, item, changeMeta) {
|
||||
var limit = Ember.get(this, limitKey);
|
||||
if (changeMeta.index < limit) {
|
||||
array.insertAt(changeMeta.index, item);
|
||||
if (Ember.get(array, "length") > limit) {
|
||||
array.popObject();
|
||||
}
|
||||
}
|
||||
return array;
|
||||
},
|
||||
removedItem: function(array, item, changeMeta) {
|
||||
var limit = Ember.get(this, limitKey);
|
||||
if (changeMeta.index < limit && changeMeta.index < Ember.get(array, 'length')) {
|
||||
array.removeAt(changeMeta.index, 1);
|
||||
var toPush = changeMeta.arrayChanged.objectAt(limit);
|
||||
if (toPush) {
|
||||
array.pushObject(toPush);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
};
|
||||
return Ember.arrayComputed(dependentKey, limitKey, options);
|
||||
return Ember.computed(dependentKey, dependentKey + ".[]", function() {
|
||||
var limit = Ember.get(this, limitKey),
|
||||
array = this.get(dependentKey);
|
||||
|
||||
return array.toArray().slice(0, limit);
|
||||
});
|
||||
};
|
||||
|
||||
export default limit;
|
||||
|
|
|
@ -4,11 +4,11 @@ window.deprecationWorkflow.config = {
|
|||
// DONE
|
||||
{ handler: "log", matchMessage: "Ember.LinkView is deprecated. Please use Ember.LinkComponent." },
|
||||
{ handler: "log", matchMessage: new RegExp("A property of .*? was modified inside the didInsertElement hook. You should never change properties on components, services or models during didInsertElement because it causes significant performance degradation.") },
|
||||
{ handler: "log", matchMessage: "Ember.arrayComputed is deprecated. Replace it with plain array methods" },
|
||||
|
||||
// TODO
|
||||
{ handler: "silence", matchMessage: "Calling store.find() with a query object is deprecated. Use store.query() instead." },
|
||||
{ handler: "silence", matchMessage: "Ember.View is deprecated. Consult the Deprecations Guide for a migration strategy." },
|
||||
{ handler: "silence", matchMessage: "Ember.arrayComputed is deprecated. Replace it with plain array methods" },
|
||||
{ handler: "silence", matchMessage: "The filter API will be moved into a plugin soon. To enable store.filter using an environment flag, or to use an alternative, you can visit the ember-data-filter addon page" },
|
||||
{ handler: "silence", matchMessage: "Usage of `state` is deprecated, use `_state` instead." },
|
||||
{ handler: "silence", matchMessage: "Function#observesBefore is deprecated and will be removed in the near future." },
|
||||
|
|
Loading…
Reference in New Issue
Block a user