View Full Version : [FIXED] LocalStorage Proxy adds IDs on every Update

20 Nov 2011, 3:48 PM

Ext version tested:

Sencha Touch 2 rev PR2
Browser versions tested against:

Mobile Safari
Android Browser
DOCTYPE tested against:

HTML5 Doctype

If you update an item in a localstorage proxy, a new ID is added to the IDs set when it is not supposed to.
This seems to happen because the code to add an ID is checking to see if the ID exists before adding it. But, the IDs in the localstorage returned by the 'getIds' function are STRINGS, whereas the ids normally provided to a local storage a INTs.
Steps to reproduce the problem:

Create a storage with a localstorage proxy.
Set a model on a store that has an ID with the type "int".
Update an item in the local store and watch the ID you just added get duplicated.
The result that was expected:

The update should not have created a new ID. It should have found the existing one.
The result that occurs instead:

A new ID is added to the local store.
It seems to only happen if your ID in the Model is a type="int".

Possible fix:

On Line 32174 of sencha-touch-all-debug-w-comments.js in PR2 change the IF statement to the following:

if (id !== undefined && Ext.Array.indexOf(ids, String(id)) == -1) {

I am just making sure that the ID provided is a string like it will be in the array of IDS provided by 'getIds()'

Jamie Avins
21 Nov 2011, 9:27 AM
Thank you for the report, we are in the middle of cleaning up a lot of data issues. I'll make sure this is part of that as well.

7 Jan 2012, 11:52 AM
Just wanted to bump this, since this bug is still present in PR 3, thanks ~o)

Jamie Avins
9 Jan 2012, 9:18 AM
The bump really does nothing, it's tracked in a separate system. We are aware that localstore has been broken during the preview and we're working through the entire data package.

9 Jan 2012, 9:19 AM
Great to hear Jamie. You guys are doing an awesome job!

16 Jan 2012, 2:27 PM
This has been fixed as part of the next Touch 2.0 release. Thanks for the report.