Поправки багов
This commit is contained in:
@@ -72,10 +72,21 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async generateNewServerStorageKey() {
|
async generateNewServerStorageKey() {
|
||||||
const key = utils.toBase58(utils.randomArray(32));
|
const key = utils.toBase58(utils.randomArray(32));
|
||||||
@@ -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,29 +431,20 @@ 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);
|
forceSaveRecent = this.sameKeyCount > 5 && (Object.keys(this.recentDelta).length > 1);
|
||||||
|
|
||||||
this.sameKeyCount = (!forceSaveRecent ? this.sameKeyCount : 0);
|
this.sameKeyCount = (!forceSaveRecent ? this.sameKeyCount : 0);
|
||||||
this.prevItemKey = itemKey;
|
this.prevItemKey = itemKey;
|
||||||
}
|
|
||||||
|
|
||||||
this.savingRecent = true;
|
this.savingRecent = true;
|
||||||
try {
|
try {
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user