Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
Safari: new storage now works; closes #985
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisaljoudi committed Mar 11, 2015
1 parent 4720ecd commit 10f656f
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions platform/safari/vapi-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,42 +137,34 @@
}
for(var i = 0; i < n; i++) {
var key = keys[i];
localforage.getItem(key, function(err, value) {
var func = function(err, value) {
toSatisfy--;
if(typeof value === "string") {
result[key] = JSON.parse(value);
result[arguments.callee.myKey] = JSON.parse(value);
}
if(toSatisfy === 0) {
callback(result);
}
});
};
func.myKey = key;
localforage.getItem(key, func);
}
}
else if(typeof keys === "object") {
var toSatisfy = 0;
for(var key in keys) {
if(!keys.hasOwnProperty(key)) {
continue;
}
toSatisfy++;
result[key] = keys[key];
}
for(var key in keys) {
if(!keys.hasOwnProperty(key)) {
continue;
localforage.iterate(function(value, key) {
if(!keys[key]) return;
if(typeof value === "string") {
result[key] = JSON.parse(value);
}
var i = key;
localforage.getItem(i, function(err, value) {
if(typeof value === "string") {
result[i] = JSON.parse(value);
}
else {
result[i] = keys[i];
}
if(--toSatisfy === 0) {
callback(result);
}
});
}
}, function() {
callback(result);
});
}
},

Expand Down

0 comments on commit 10f656f

Please sign in to comment.