diff --git a/client/components/Reader/ServerStorage/ServerStorage.vue b/client/components/Reader/ServerStorage/ServerStorage.vue index d28e3dd0..b6092ddb 100644 --- a/client/components/Reader/ServerStorage/ServerStorage.vue +++ b/client/components/Reader/ServerStorage/ServerStorage.vue @@ -69,15 +69,15 @@ class ServerStorage extends Vue { try { this.cachedRecent = await ssCacheStore.getItem('recent'); if (!this.cachedRecent) - await this.setCachedRecent({rev: 0, data: {}}); + await this.cleanCachedRecent('cachedRecent'); this.cachedRecentPatch = await ssCacheStore.getItem('recent-patch'); if (!this.cachedRecentPatch) - await this.setCachedRecentPatch({rev: 0, data: {}}); + await this.cleanCachedRecent('cachedRecentPatch'); this.cachedRecentMod = await ssCacheStore.getItem('recent-mod'); if (!this.cachedRecentMod) - await this.setCachedRecentMod({rev: 0, data: {}}); + await this.cleanCachedRecent('cachedRecentMod'); if (!this.serverStorageKey) { //генерируем новый ключ @@ -105,6 +105,15 @@ class ServerStorage extends Vue { 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() { const key = utils.toBase58(utils.randomArray(32)); this.commit('reader/setServerStorageKey', key); @@ -134,9 +143,12 @@ class ServerStorage extends Vue { await this.currentProfileChanged(force); await this.loadLibs(force); + if (force) + await this.cleanCachedRecent('all'); const loadSuccess = await this.loadRecent(); - if (loadSuccess && force) + if (loadSuccess && force) { await this.saveRecent(); + } } }