Исправлен баг синхронизации при первом включении опции

This commit is contained in:
Book Pauk
2020-11-01 11:23:15 +07:00
parent add7a03f88
commit 1dad013d60

View File

@@ -69,15 +69,15 @@ class ServerStorage extends Vue {
try { try {
this.cachedRecent = await ssCacheStore.getItem('recent'); this.cachedRecent = await ssCacheStore.getItem('recent');
if (!this.cachedRecent) if (!this.cachedRecent)
await this.setCachedRecent({rev: 0, data: {}}); await this.cleanCachedRecent('cachedRecent');
this.cachedRecentPatch = await ssCacheStore.getItem('recent-patch'); this.cachedRecentPatch = await ssCacheStore.getItem('recent-patch');
if (!this.cachedRecentPatch) if (!this.cachedRecentPatch)
await this.setCachedRecentPatch({rev: 0, data: {}}); await this.cleanCachedRecent('cachedRecentPatch');
this.cachedRecentMod = await ssCacheStore.getItem('recent-mod'); this.cachedRecentMod = await ssCacheStore.getItem('recent-mod');
if (!this.cachedRecentMod) if (!this.cachedRecentMod)
await this.setCachedRecentMod({rev: 0, data: {}}); await this.cleanCachedRecent('cachedRecentMod');
if (!this.serverStorageKey) { if (!this.serverStorageKey) {
//генерируем новый ключ //генерируем новый ключ
@@ -105,6 +105,15 @@ class ServerStorage extends Vue {
this.cachedRecentMod = value; this.cachedRecentMod = value;
} }
async cleanCachedRecent(whatToClean) {
if (whatToClean == 'cachedRecent' || whatToClean == 'all')
await this.setCachedRecent({rev: 0, data: {}});
if (whatToClean == 'cachedRecentPatch' || whatToClean == 'all')
await this.setCachedRecentPatch({rev: 0, data: {}});
if (whatToClean == 'cachedRecentMod' || whatToClean == 'all')
await this.setCachedRecentMod({rev: 0, data: {}});
}
async generateNewServerStorageKey() { async generateNewServerStorageKey() {
const key = utils.toBase58(utils.randomArray(32)); const key = utils.toBase58(utils.randomArray(32));
this.commit('reader/setServerStorageKey', key); this.commit('reader/setServerStorageKey', key);
@@ -134,9 +143,12 @@ class ServerStorage extends Vue {
await this.currentProfileChanged(force); await this.currentProfileChanged(force);
await this.loadLibs(force); await this.loadLibs(force);
if (force)
await this.cleanCachedRecent('all');
const loadSuccess = await this.loadRecent(); const loadSuccess = await this.loadRecent();
if (loadSuccess && force) if (loadSuccess && force) {
await this.saveRecent(); await this.saveRecent();
}
} }
} }