Поправки багов

This commit is contained in:
Book Pauk
2019-03-22 20:14:33 +07:00
parent 92d929b704
commit 3f6b468021
2 changed files with 29 additions and 5 deletions

View File

@@ -310,14 +310,24 @@ class Reader extends Vue {
} }
if (eventName == 'recent-changed' || eventName == 'save-recent') { if (eventName == 'recent-changed' || eventName == 'save-recent') {
if (this.historyActive) {
this.$refs.historyPage.updateTableData();
}
(async() => { (async() => {
const oldBook = this.mostRecentBookReactive; const oldBook = this.mostRecentBookReactive;
const newBook = bookManager.mostRecentBook(); const newBook = bookManager.mostRecentBook();
if (oldBook && newBook) { if (oldBook && newBook) {
if (oldBook.key != newBook.key) { if (oldBook.key != newBook.key) {
await this.loadBook(newBook); this.loadingBook = true;
try {
await this.loadBook(newBook);
} finally {
this.loadingBook = false;
}
} else if (oldBook.bookPos != newBook.bookPos) { } else if (oldBook.bookPos != newBook.bookPos) {
while (this.loadingBook) await utils.sleep(100);
this.bookPosChanged({bookPos: newBook.bookPos}); this.bookPosChanged({bookPos: newBook.bookPos});
} }
} }

View File

@@ -62,7 +62,7 @@ class ServerStorage extends Vue {
await this.currentProfileChanged(); await this.currentProfileChanged();
await this.loadRecent(); await this.loadRecent();
this.oldRecent = _.cloneDeep(bookManager.recent); this.oldRecent = _.cloneDeep(bookManager.recent);
this.oldRecentLast = _.cloneDeep(bookManager.recentLast); this.oldRecentLast = _.cloneDeep(bookManager.recentLast) || {};
} finally { } finally {
this.inited = true; this.inited = true;
} }
@@ -71,7 +71,7 @@ class ServerStorage extends Vue {
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);
await this.serverStorageKeyChanged(); await this.serverStorageKeyChanged(true);
} }
async serverSyncEnabledChanged() { async serverSyncEnabledChanged() {
@@ -89,6 +89,8 @@ class ServerStorage extends Vue {
await this.loadProfiles(force); await this.loadProfiles(force);
this.checkCurrentProfile(); this.checkCurrentProfile();
await this.loadRecent(); await this.loadRecent();
if (force)
await this.saveRecent();
} }
} }
@@ -462,6 +464,7 @@ class ServerStorage extends Vue {
const bm = bookManager; const bm = bookManager;
let recentLast = bm.recentLast; let recentLast = bm.recentLast;
recentLast = (recentLast ? recentLast : {}); recentLast = (recentLast ? recentLast : {});
let lastRev = bm.recentLastRev;
const diff = utils.getObjDiff(this.oldRecentLast, recentLast); const diff = utils.getObjDiff(this.oldRecentLast, recentLast);
if (utils.isEmptyObjDiff(diff)) if (utils.isEmptyObjDiff(diff))
@@ -472,8 +475,19 @@ class ServerStorage extends Vue {
let result = {state: ''}; let result = {state: ''};
let tries = 0; let tries = 0;
while (result.state != 'success' && tries < maxSetTries) { while (result.state != 'success' && tries < maxSetTries) {
if (force) {
try {
const revs = await this.storageCheck({recentLast: {}});
if (revs.items.recentLast.rev)
lastRev = revs.items.recentLast.rev;
} catch(e) {
this.error(`Ошибка соединения с сервером: ${e.message}`);
return;
}
}
try { try {
result = await this.storageSet({recentLast: {rev: bm.recentLastRev + 1, data: recentLast}}, force); result = await this.storageSet({recentLast: {rev: lastRev + 1, data: recentLast}}, force);
} catch(e) { } catch(e) {
this.savingRecentLast = false; this.savingRecentLast = false;
this.error(`Ошибка соединения с сервером: (${e.message}). Изменения не сохранены.`); this.error(`Ошибка соединения с сервером: (${e.message}). Изменения не сохранены.`);
@@ -494,7 +508,7 @@ class ServerStorage extends Vue {
this.error('Не удалось отправить данные на сервер. Данные не сохранены и могут быть перезаписаны.'); this.error('Не удалось отправить данные на сервер. Данные не сохранены и могут быть перезаписаны.');
} else { } else {
this.oldRecentLast = _.cloneDeep(recentLast); this.oldRecentLast = _.cloneDeep(recentLast);
await bm.setRecentLastRev(bm.recentLastRev + 1); await bm.setRecentLastRev(lastRev + 1);
} }
} finally { } finally {
this.savingRecentLast = false; this.savingRecentLast = false;