Skip to content

Commit

Permalink
Remove some more computeds
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbieTheWagner committed Oct 25, 2024
1 parent 068d8f9 commit 8109162
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
10 changes: 4 additions & 6 deletions app/controllers/promise-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { action } from '@ember/object';
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { isEmpty } from '@ember/utils';
import { filter } from '@ember/object/computed';
import { debounce, next, once } from '@ember/runloop';
import { tracked } from '@glimmer/tracking';

Expand Down Expand Up @@ -38,9 +37,8 @@ export default class PromiseTreeController extends Controller {
// It is opt-in due to performance reasons.
@tracked instrumentWithStack = false;

filtered = filter(
'model.@each.{createdAt,fulfilledBranch,rejectedBranch,pendingBranch,isVisible}',
function (item) {
get filtered() {
return this.model.filter((item) => {
// exclude cleared promises
if (this.createdAfter && item.get('createdAt') < this.createdAfter) {
return false;
Expand Down Expand Up @@ -73,8 +71,8 @@ export default class PromiseTreeController extends Controller {
return item.matches(search);
}
return true;
},
);
});
}

// eslint-disable-next-line ember/no-observers
@observes('searchValue')
Expand Down
31 changes: 16 additions & 15 deletions app/models/promise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { observes } from '@ember-decorators/object';
import { or, equal, not } from '@ember/object/computed';
import { once } from '@ember/runloop';
import { typeOf, isEmpty } from '@ember/utils';
// eslint-disable-next-line ember/no-observers
Expand Down Expand Up @@ -31,7 +30,9 @@ export default class Promise extends EmberObject {
settledAt;

@tracked branchLabel = '';
parent = null;
@tracked isExpanded = false;
@tracked isManuallyExpanded = undefined;
@tracked parent = null;
@computed('parent.level')
get level() {
Expand All @@ -42,17 +43,21 @@ export default class Promise extends EmberObject {
return parent.get('level') + 1;
}
@or('isFulfilled', 'isRejected')
isSettled;
get isSettled() {
return this.isFulfilled || this.isRejected;
}
@equal('state', 'fulfilled')
isFulfilled;
get isFulfilled() {
return this.state === 'fulfilled';
}
@equal('state', 'rejected')
isRejected;
get isRejected() {
return this.state === 'rejected';
}
@not('isSettled')
isPending;
get isPending() {
return !this.isSettled;
}
children = [];
Expand Down Expand Up @@ -138,10 +143,6 @@ export default class Promise extends EmberObject {

// EXPANDED / COLLAPSED PROMISES

isExpanded = false;

isManuallyExpanded = undefined;

// eslint-disable-next-line ember/no-observers
@observes('isPending', 'isFulfilled', 'isRejected', 'parent')
stateOrParentChanged() {
Expand Down Expand Up @@ -187,7 +188,7 @@ export default class Promise extends EmberObject {
this.parent.recalculateExpanded();
}
}
this.set('isExpanded', isExpanded);
this.isExpanded = isExpanded;
return isExpanded;
}

Expand Down

0 comments on commit 8109162

Please sign in to comment.