Skip to content

Commit

Permalink
fix: add ember-data version check to check if calling .toArray on e…
Browse files Browse the repository at this point in the history
…mber-data arrays is deprecated
  • Loading branch information
StephanH90 committed Oct 26, 2023
1 parent 9e9680e commit 6a548fb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/addon/services/-scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { assert } from "@ember/debug";
import { once } from "@ember/runloop";
import Service, { inject as service } from "@ember/service";
import { camelize } from "@ember/string";
import { dependencySatisfies } from "@embroider/macros";
import { tracked } from "@glimmer/tracking";
import { task } from "ember-concurrency";
import { pluralize } from "ember-inflector";

const toArrayIsDeprecated = dependencySatisfies("ember-data", "^4.7.0");

/**
* Decorator to define a type resolver in the scheduler service.
*
Expand Down Expand Up @@ -37,7 +40,9 @@ function typeResolver(type) {
? yield this.calumaOptions[methodName]?.(uncachedIdentifiers)
: [];

const allResults = [...cached, ...(result?.toArray?.() ?? result ?? [])];
const allResults = toArrayIsDeprecated
? [...cached, ...(result ?? [])]
: [...cached, ...(result?.toArray?.() ?? result ?? [])];

if (result?.length) {
this[`${type}Cache`] = allResults;
Expand Down

0 comments on commit 6a548fb

Please sign in to comment.