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

Long time to delete a record #49

Closed zalun closed 9 years ago

zalun commented 9 years ago

I've got pretty big records to save (each has 3 png portrait images of 900px width) I'm using Ember under Cordova, testing on FirefoxOS nightly installed on Sony Z3 Compact. When there is only a few of the records, deleting takes 2s, which is OK, but when the number of records is about 60 - it takes 40s to delete a record. Is this normal?

The code is still in development - there is no paging, but I don't think it's really needed. To load the list -- findAll: https://github.com/zalun/stereophoto/blob/master/ember-stereophoto/app/routes/stereos/first-run.js To display after the delete I'm using peekAll: IndexRoute: https://github.com/zalun/stereophoto/blob/master/ember-stereophoto/app/routes/stereos/index.js Adapter: https://github.com/zalun/stereophoto/blob/master/ember-stereophoto/app/adapters/stereo.js Model: https://github.com/zalun/stereophoto/blob/master/ember-stereophoto/app/models/stereo.js Route: https://github.com/zalun/stereophoto/blob/master/ember-stereophoto/app/router.js

frederikbosch commented 9 years ago

A limitation of the current localforage adapter is that everything is stored in a single key. How are tests with a browser Chrome doing? What is the size of your PNG?

In one of my own applications I stored a photo reference in the model, and stored the photo itself in a separate localforage key. You might consider that. Storing photos inside a database might not be best practise in this case.

zalun commented 9 years ago

Using 2 models should definitely work better for the first list view.

frederikbosch commented 9 years ago

@zalun I would not store the image using the Ember Store

// maybe inside route::model
var model = this.store.find('your-model-name', params.model_id);

// maybe inside route::setupController
var pictureName = model.get('pictureAttr');
this.imageRepository.find(pictureName).then((image) => {
  controller.set('image', image);
});
zalun commented 9 years ago

I think I'll add an attribute with promise to the component/controller to retrieve images which will have the key related to the model id.

zalun commented 9 years ago

Thanks for the advices - I'll close the issue then