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)
29 lines
764 B
JavaScript
29 lines
764 B
JavaScript
/* eslint-disable camelcase */
|
|
import Transform from '@ember-data/serializer/transform';
|
|
import UnsplashObject from 'ghost-admin/models/unsplash-integration';
|
|
|
|
const DEFAULT_SETTINGS = {
|
|
isActive: true
|
|
};
|
|
|
|
export default Transform.extend({
|
|
deserialize(serialized) {
|
|
if (serialized) {
|
|
let settingsObject;
|
|
try {
|
|
settingsObject = JSON.parse(serialized) || DEFAULT_SETTINGS;
|
|
} catch (e) {
|
|
settingsObject = DEFAULT_SETTINGS;
|
|
}
|
|
|
|
return UnsplashObject.create(settingsObject);
|
|
}
|
|
|
|
return DEFAULT_SETTINGS;
|
|
},
|
|
|
|
serialize(deserialized) {
|
|
return deserialized ? JSON.stringify(deserialized) : JSON.stringify(DEFAULT_SETTINGS);
|
|
}
|
|
});
|