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

This commit is contained in:
Book Pauk
2019-09-20 16:54:03 +07:00
parent 49b3f05d65
commit 9e296231d9

View File

@@ -72,8 +72,19 @@ class ServerStorage extends Vue {
async bookManagerEvent(eventName, itemKey) { async bookManagerEvent(eventName, itemKey) {
if (eventName == 'recent-changed') { if (eventName == 'recent-changed') {
if (itemKey) if (itemKey) {
if (!this.recentDeltaInited) {
this.warning('Функции сохранения на сервер пока недоступны');
return;
}
if (!this.recentDelta)
this.recentDelta = {};
this.recentDelta[itemKey] = _.cloneDeep(bookManager.recent[itemKey]);
this.debouncedSaveRecent(itemKey); this.debouncedSaveRecent(itemKey);
}
} }
} }
@@ -394,7 +405,7 @@ class ServerStorage extends Vue {
this.recentDelta = recentDelta.data; this.recentDelta = recentDelta.data;
} else { } else {
newRecent = recent.data; newRecent = recent.data;
this.recentDelta = null; this.recentDelta = {};
} }
this.recentDeltaInited = true; this.recentDeltaInited = true;
@@ -420,30 +431,21 @@ class ServerStorage extends Vue {
const bm = bookManager; const bm = bookManager;
if (!this.recentDeltaInited) {
this.warning('Функции сохранения на сервер пока недоступны');
return;
}
if (!this.recentDelta)
this.recentDelta = {};
this.recentDelta[itemKey] = _.cloneDeep(bm.recent[itemKey]);
//вычисление критерия сохранения целиком //вычисление критерия сохранения целиком
let forceSaveRecent = false; let forceSaveRecent = false;
if (!forceSaveRecent && itemKey) { if (!this.sameKeyCount)
if (!this.sameKeyCount) this.sameKeyCount = 0;
this.sameKeyCount = 0; if (this.prevItemKey == itemKey) {
if (this.prevItemKey == itemKey) this.sameKeyCount++;
this.sameKeyCount++; } else {
this.sameKeyCount = 0;
forceSaveRecent = this.sameKeyCount > 5 && (Object.keys(this.recentDelta).length > 1);
this.sameKeyCount = (!forceSaveRecent ? this.sameKeyCount : 0);
this.prevItemKey = itemKey;
} }
forceSaveRecent = this.sameKeyCount > 5 && (Object.keys(this.recentDelta).length > 1);
this.sameKeyCount = (!forceSaveRecent ? this.sameKeyCount : 0);
this.prevItemKey = itemKey;
this.savingRecent = true; this.savingRecent = true;
try { try {
if (forceSaveRecent) {//сохраняем recent целиком if (forceSaveRecent) {//сохраняем recent целиком
@@ -460,6 +462,7 @@ class ServerStorage extends Vue {
this.warning(`Последние изменения отменены. Данные синхронизированы с сервером.`); this.warning(`Последние изменения отменены. Данные синхронизированы с сервером.`);
if (!recurse) { if (!recurse) {
this.savingRecent = false; this.savingRecent = false;
this.recentDelta[itemKey] = _.cloneDeep(bm.recent[itemKey]);
this.saveRecent(itemKey, true); this.saveRecent(itemKey, true);
return; return;
} }
@@ -482,6 +485,7 @@ class ServerStorage extends Vue {
this.warning(`Последние изменения отменены. Данные синхронизированы с сервером.`); this.warning(`Последние изменения отменены. Данные синхронизированы с сервером.`);
if (!recurse) { if (!recurse) {
this.savingRecent = false; this.savingRecent = false;
this.recentDelta[itemKey] = _.cloneDeep(bm.recent[itemKey]);
this.saveRecent(itemKey, true); this.saveRecent(itemKey, true);
return; return;
} }