Skip to content

Commit

Permalink
fix Run loop and computed dot access deprecation (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
phndiaye authored Jul 25, 2024
1 parent d9d3132 commit b1e34d4
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions addon/components/hyper-table/facetting.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Component from '@ember/component';
import { isEmpty } from '@ember/utils';
import { run } from '@ember/runloop';
import { later } from '@ember/runloop';
import { set } from '@ember/object';

export default Component.extend({
Expand All @@ -21,7 +21,7 @@ export default Component.extend({
this.onToggleAppliedFacet(facet);
}

run.later(() => {
later(() => {
this.column.applyFacets(
this.filteringKey,
this.facets.filter((f) => {
Expand Down
4 changes: 2 additions & 2 deletions addon/components/hyper-table/filters-renderers/numeric.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Component from '@ember/component';
import { computed, observer } from '@ember/object';
import { run } from '@ember/runloop';
import { debounce } from '@ember/runloop';

import FiltersRendererMixin from '@upfluence/hypertable/mixins/filters-renderer';

Expand Down Expand Up @@ -32,7 +32,7 @@ export default Component.extend(FiltersRendererMixin, {

_: observer('lowerBoundFilter', 'upperBoundFilter', function () {
if (this.lowerBoundFilter || this.upperBoundFilter) {
run.debounce(this, this._addRangeFilter, 1000);
debounce(this, this._addRangeFilter, 1000);
}
}),

Expand Down
4 changes: 2 additions & 2 deletions addon/components/hyper-table/filters-renderers/text.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Component from '@ember/component';
import { observer, computed } from '@ember/object';
import { run } from '@ember/runloop';
import { debounce } from '@ember/runloop';
import { isEmpty } from '@ember/utils';

import FiltersRendererMixin from '@upfluence/hypertable/mixins/filters-renderer';
Expand Down Expand Up @@ -41,7 +41,7 @@ export default Component.extend(FiltersRendererMixin, {
},

_searchQueryObserver: observer('_searchQuery', function () {
run.debounce(this, this._addSearchFilter, 1000);
debounce(this, this._addSearchFilter, 1000);
}),

init() {
Expand Down
10 changes: 5 additions & 5 deletions addon/components/hyper-table/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { A } from '@ember/array';
import Component from '@ember/component';
import { computed, observer } from '@ember/object';
import { alias, filterBy } from '@ember/object/computed';
import { run, once } from '@ember/runloop';
import { alias, and, filterBy } from '@ember/object/computed';
import { debounce, once, scheduleOnce } from '@ember/runloop';
import { compare, isEmpty, typeOf } from '@ember/utils';
import $ from 'jquery';

Expand Down Expand Up @@ -39,7 +39,7 @@ export default Component.extend({
},
set: function (k, v) {
this._columns.firstObject.set('filters', isEmpty(v) ? [] : [{ key: 'value', value: v }]);
run.debounce(this, this._doSearch, 1000);
debounce(this, this._doSearch, 1000);
return v;
}
}),
Expand Down Expand Up @@ -106,7 +106,7 @@ export default Component.extend({
return this.groupByClusteringKey(fields);
}),

_loadingMore: computed.and('manager.hooks.onBottomReached', 'loadingMore'),
_loadingMore: and('manager.hooks.onBottomReached', 'loadingMore'),

_setAllRowSelected(value) {
this.manager.set('_allRowsSelected', value);
Expand Down Expand Up @@ -172,7 +172,7 @@ export default Component.extend({
}

// eslint-disable-next-line ember/no-incorrect-calls-with-inline-anonymous-functions
run.scheduleOnce('afterRender', this, () => {
scheduleOnce('afterRender', this, () => {
let table = document.querySelector('.hypertable');
$(table).scroll(() => {
if (table.scrollLeft === table.scrollWidth - table.clientWidth) {
Expand Down
4 changes: 2 additions & 2 deletions addon/components/hyper-table/views.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { run } from '@ember/runloop';
import { debounce } from '@ember/runloop';
import { isPresent } from '@ember/utils';

const SEARCH_DEBOUNCE = 500;
Expand All @@ -25,7 +25,7 @@ export default class ViewsComponent extends Component {

@action
onSearchChange() {
run.debounce(this, this.filterViews, SEARCH_DEBOUNCE);
debounce(this, this.filterViews, SEARCH_DEBOUNCE);
}

@action
Expand Down
4 changes: 2 additions & 2 deletions addon/mixins/cell-renderer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Mixin from '@ember/object/mixin';
import { computed } from '@ember/object';
import { empty } from '@ember/object/computed';
import { empty, oneWay } from '@ember/object/computed';

export default Mixin.create({
classNameBindings: ['emptyValue'],
Expand All @@ -10,6 +10,6 @@ export default Mixin.create({
return this.item.get(this.column.key);
}),

editableValue: computed.oneWay('value'),
editableValue: oneWay('value'),
emptyValue: empty('value')
});
15 changes: 8 additions & 7 deletions addon/mixins/editable.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Mixin from '@ember/object/mixin';
import EmberObject, { computed } from '@ember/object';
import { run } from '@ember/runloop';
import { equal } from '@ember/object/computed';
import { scheduleOnce } from '@ember/runloop';

export default Mixin.create({
classNameBindings: ['editStatus.status', 'isUpsertable'],
Expand All @@ -9,11 +10,11 @@ export default Mixin.create({
return this.manager.get('editStatus').findBy('id', this.element.id);
}),

isSuccess: computed.equal('editStatus.status', 'success'),
isEditing: computed.equal('editStatus.status', 'editing'),
isSaving: computed.equal('editStatus.status', 'saving'),
isError: computed.equal('editStatus.status', 'error'),
isUpsertable: computed.equal('column.upsertable', true),
isSuccess: equal('editStatus.status', 'success'),
isEditing: equal('editStatus.status', 'editing'),
isSaving: equal('editStatus.status', 'saving'),
isError: equal('editStatus.status', 'error'),
isUpsertable: equal('column.upsertable', true),

actions: {
toggleEditing(value, autosave = false) {
Expand Down Expand Up @@ -72,7 +73,7 @@ export default Mixin.create({

// automatically focuses the input
// eslint-disable-next-line ember/no-incorrect-calls-with-inline-anonymous-functions
run.scheduleOnce('afterRender', this, () => {
scheduleOnce('afterRender', this, () => {
this.$('.editing-input__field').focus();
});
},
Expand Down

0 comments on commit b1e34d4

Please sign in to comment.