Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
clean up extra key from amplify.store <1.0.0
// Prior to 1.0.0, amplify.store created a key to track all of the values
// that were stored. The 1.0.0 release no longer uses this key and as a
// result, if you ask for all of the values (using amplify.store()) you'll
// get back one extra value.
//
// Simply include this code after you include amplify.store and it will
// remove the extra key. You'll want to include this anywhere that you
// have previously used amplify.store.
(function() {
var types = amplify.store.types;
if ( types.localStorage ) {
localStorage.removeItem( "__amplify__" );
}
if ( types.sessionStorage ) {
sessionStorage.removeItem( "__amplify__" );
}
if ( types.globalStorage ) {
globalStorage[ location.hostname ].removeItem( "__amplify__" );
}
if ( types.userData ) {
var div = document.createElement( "div" );
document.getElementsByTagName( "head" )[ 0 ].appendChild( div );
div.addBehavior( "#default#userdata" );
div.load( "amplify" );
div.removeAttribute( "amplify" );
div.save( "amplify" );
div.parentNode.removeChild( div );
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment