Commit bc07a189 by Иван Кубота

store version

parent 4dfde94a
let latest;
let latest, STORE_VERSION = 'v0.1';
const store = new Store(latest = {
commit: window.CommitID,
_VERSION_: STORE_VERSION,
'navigation': {
current: 'Login'
},
......@@ -16,23 +16,23 @@ const store = new Store(latest = {
try{
var data = JSON.parse( localStorage.getItem( 'store' ) );
if(data.commit !== store.get('commit')){
if(data._VERSION_ !== store.get('_VERSION_')){
console.warn('STORE:outdated, new state → localStorage');
console.warn('\tSTORE:currentData #'+ store.get('commit'), store._props);
console.warn('\tSTORE:savedData # '+ window.CommitID, data);
console.warn('\tSTORE:currentData #'+ store.get('_VERSION_'), store._props);
console.warn('\tSTORE:savedData # '+ STORE_VERSION, data);
console.warn('\tSTORE:hint → Run Store.restore() for restore saved state');
console.warn('\tStore:hint → Run Store.update() for load latest default state');
Store.restore = function() {
for( var k in data ){
if(k !== 'commit'){
if(k !== '_VERSION_'){
store.set( k, data[ k ] );
}
}
};
Store.update = function() {
for( var k in latest ){
if(k !== 'commit'){
if(k !== '_VERSION_'){
store.set( k, latest[ k ] );
}
}
......@@ -51,11 +51,11 @@ store.on('change', function() {
const createSavableStore = function(name) {
const store = new Store(latest = {
commit: window.CommitID
_VERSION_: STORE_VERSION
});
try{
var data = JSON.parse( localStorage.getItem( name ) );
if(data.commit === store.get('commit')){
if(data._VERSION_ === store.get('_VERSION_')){
for( var k in data ){
store.set( k, data[ k ] );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment