Skip to content

Commit

Permalink
Merge pull request #61 from rmmmp/fix-regressions
Browse files Browse the repository at this point in the history
Fix regressions
  • Loading branch information
mikkopaderes authored May 16, 2018
2 parents 43fe38a + fac366e commit 0f06752
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 4 additions & 8 deletions addon/serializers/cloud-firestore.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { inject } from '@ember/service';
import { pluralize } from 'ember-inflector';
import { typeOf } from '@ember/utils';
import JSONSerializer from 'ember-data/serializers/json';

import {
Expand All @@ -25,11 +26,7 @@ export default JSONSerializer.extend({
* @override
*/
extractRelationship(relationshipModelName, relationshipHash) {
if (
relationshipHash !== null
&& typeof relationshipHash === 'object'
&& relationshipHash.firestore
) {
if (typeOf(relationshipHash) === 'object' && relationshipHash.firestore) {
const path = buildPathFromRef(relationshipHash);
const pathNodes = path.split('/');
const belongsToId = pathNodes[pathNodes.length - 1];
Expand All @@ -53,8 +50,7 @@ export default JSONSerializer.extend({
if (descriptor.kind === 'belongsTo') {
if (
Object.prototype.hasOwnProperty.call(resourceHash, name)
&& resourceHash[name] !== null
&& typeof resourceHash[name] === 'object'
&& typeOf(resourceHash[name]) === 'object'
&& resourceHash[name].firestore
) {
const path = buildPathFromRef(resourceHash[name]);
Expand Down Expand Up @@ -153,7 +149,7 @@ export default JSONSerializer.extend({
getAdapterOptionAttribute(snapshot, key) {
if (
snapshot.adapterOptions
&& Object.prototype.hasOwnProperty.call(snapshot, key)
&& Object.prototype.hasOwnProperty.call(snapshot.adapterOptions, key)
) {
return snapshot.adapterOptions[key];
}
Expand Down
6 changes: 5 additions & 1 deletion addon/transforms/timestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ export default Transform.extend({
* @override
*/
deserialize(serialized) {
return serialized.toDate();
if (typeOf(serialized) === 'object' && serialized.toDate) {
return serialized.toDate();
}

return serialized;
},

/**
Expand Down

0 comments on commit 0f06752

Please sign in to comment.