From 26751acdec138f9c748b6018a54442058f58520a Mon Sep 17 00:00:00 2001 From: Jeff Niu Date: Tue, 19 Dec 2017 13:25:36 -0800 Subject: [PATCH] Added fallback to localstorage --- addon/helpers/storage.js | 5 +++++ addon/serializers/serializer.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/addon/helpers/storage.js b/addon/helpers/storage.js index 67531b20..653b1dc9 100644 --- a/addon/helpers/storage.js +++ b/addon/helpers/storage.js @@ -61,6 +61,11 @@ function tryStorage(name) { } function getStorage(name) { + // Attempt to fall back to localStorage if the provided + // type is not supported, ignoring custom drivers + if (!localforage.supports(name) && !customDrivers[name]) { + name = 'local'; + } if (storage[name]) { return storage[name]; } else { diff --git a/addon/serializers/serializer.js b/addon/serializers/serializer.js index c5488dfe..a49405bd 100644 --- a/addon/serializers/serializer.js +++ b/addon/serializers/serializer.js @@ -9,7 +9,7 @@ export default JSONAPISerializer.extend({ _shouldSerializeHasMany: function() { return true; }, shouldSerializeHasMany: function() { return true; }, // Ensure that returned data is null if undefined - normalizeResponse(store, modelClass, payload, id, requestType) { + normalizeResponse() { const result = this._super(...arguments); if (result.data === undefined) { result.data = null;