Last active
January 26, 2016 14:59
-
-
Save eppfel/de8b5b614682232e518b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var interactionsCollection = []; | |
localforage.getItem('Interactions').then(function (interactionKeys) { | |
interactionKeys.forEach(function(key) { | |
localforage.getItem(key).then(function (data) { interactionsCollection.push(data)})}) | |
}); | |
var allInteractions = []; | |
var keyc = 0; | |
localforage.keys(function(keys) { | |
keys.forEach(function (key){ | |
keyc++; | |
if (-1 < key.search(/^Interaction\/.+/)) { | |
localforage.getItem(key).then(function (value) {allInteractions.push(value);}); | |
} | |
}); | |
}); | |
//This has to be executed afterwards, because the operations are asynchronous, but not yet combined | |
var missing = allInteractions.filter(function (interaction) { | |
return !interactionsCollection.some(function (colInteraction){ | |
return colInteraction.id == interaction.id; | |
}); | |
}); | |
//Obsolete: Compare and update | |
// function doctor() { | |
localforage.getItem('Interactions').then(function (interactionsCollection) { | |
localforage.keys(function(storageKeys) { | |
var tmpCollection = interactionsCollection; | |
storageKeys.forEach(function (key) { | |
if (key.search(/^Interaction\/.+/) > -1 ) { | |
var i = tmpCollection.indexOf(key); | |
if (i > -1) { | |
tmpCollection.splice(i,1); | |
} | |
else { | |
interactionsCollection.push(key); | |
} | |
} | |
}); | |
localforage.setItem('Interactions',interactionsCollection); | |
}); | |
}); | |
// } | |
//*******************************// | |
// Careful deletes all Rose data // | |
//*******************************// | |
localforage.clear(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment