mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
ba4c53134f
no issue - update imports for `@ember-data` package (https://github.com/emberjs/rfcs/blob/master/text/0395-ember-data-packages.md) - use `computed.reads` where applicable (https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/require-computed-macros.md) - fix usage of `scheduleOnce` so that functions are only scheduled once (https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/no-incorrect-calls-with-inline-anonymous-functions.md)
32 lines
887 B
JavaScript
32 lines
887 B
JavaScript
import MemberSubscription from 'ghost-admin/models/member-subscription';
|
|
import Transform from '@ember-data/serializer/transform';
|
|
import {A as emberA, isArray as isEmberArray} from '@ember/array';
|
|
|
|
export default Transform.extend({
|
|
deserialize(serialized) {
|
|
let subscriptions, subscriptionArray;
|
|
|
|
subscriptionArray = serialized.subscriptions || [];
|
|
|
|
subscriptions = subscriptionArray.map(itemDetails => MemberSubscription.create(itemDetails));
|
|
|
|
return emberA(subscriptions);
|
|
},
|
|
|
|
serialize(deserialized) {
|
|
let subscriptionArray;
|
|
|
|
if (isEmberArray(deserialized)) {
|
|
subscriptionArray = deserialized.map((item) => {
|
|
return item;
|
|
}).compact();
|
|
} else {
|
|
subscriptionArray = [];
|
|
}
|
|
|
|
return {
|
|
subscriptions: subscriptionArray
|
|
};
|
|
}
|
|
});
|