genkgo / ember-localforage-adapter

Offline usage for Ember Data, based on localstorage adapter, but now uses Mozilla's localforage as data source
Other
133 stars 26 forks source link

getting init issue in safari #69

Closed sankar-ganesh closed 6 years ago

sankar-ganesh commented 7 years ago

On initial load or when user come back after clearing the local store we see init problem only in web safari browser.

On init we are trying to set default values into the indexDB. Appreciate your help!!! Thanks

PS: No error in browser console

frederikbosch commented 7 years ago

This needs more clarification. Show me something of your code. What Ember version are you on? What version of the adapter?

sankar-ganesh commented 7 years ago

Ember Version : 2.4.1

This is the adapter

import Ember from 'ember';
import LFAdapter from 'ember-localforage-adapter/adapters/localforage';

const {
  computed,
  inject
} = Ember;

export default LFAdapter.extend({
  session: inject.service('session'),

  namespace: computed('session.appId', {
    get: function() {
      var appId = this.get('session.appId');
      return appId && appId.toString();
    }
  }),

  caching: 'all'
});

In route I am doing this

model: function() {
    return this.store.findAll("datastore");
},

afterModel: function(model) {
   var session = this.get('session.appId'), 
         datastore = model && model.findBy("appId", appId);
   if (datastore) {
      // data available
   } else {
      // load datastore
      datastore = this.store.createRecord('datastore', {
               appId: appId,
               messages: Ember.A([])
     });
     return datastore.save();
   }
}
frederikbosch commented 7 years ago

What if you add localforage to your bower.json with version 1.5.0? Maybe there is a bug fixed for safari.

frederikbosch commented 7 years ago

If so, we could update this package to reference a newer localforage version.

sankar-ganesh commented 7 years ago

works like a champ :-) thanks!!!

shall we continue pointing to 1.5.0?

frederikbosch commented 7 years ago

Yeah, if you could create a PR with the new version, that would be great.

frederikbosch commented 6 years ago

Locaforage updated to latest version, closed.