Убрал устаревший код
This commit is contained in:
@@ -585,7 +585,11 @@ class Reader {
|
|||||||
//сохранение в serverStorage
|
//сохранение в serverStorage
|
||||||
if (value) {
|
if (value) {
|
||||||
await utils.sleep(500);
|
await utils.sleep(500);
|
||||||
await this.$refs.serverStorage.saveRecent(value);
|
try {
|
||||||
|
await this.$refs.serverStorage.saveRecent(value);
|
||||||
|
} catch (e) {
|
||||||
|
this.$root.notify.error(e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -627,7 +627,7 @@ class ServerStorage {
|
|||||||
this.warning(`Последние изменения отменены. Данные синхронизированы с сервером.`);
|
this.warning(`Последние изменения отменены. Данные синхронизированы с сервером.`);
|
||||||
if (!recurse && itemKey) {
|
if (!recurse && itemKey) {
|
||||||
this.savingRecent = false;
|
this.savingRecent = false;
|
||||||
this.saveRecent(itemKey, true);
|
await this.saveRecent(itemKey, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (result.state == 'success') {
|
} else if (result.state == 'success') {
|
||||||
|
|||||||
@@ -63,48 +63,6 @@ class BookManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await this.cleanRecentBooks();
|
await this.cleanRecentBooks();
|
||||||
|
|
||||||
//TODO: убрать после 06.2021, когда bmRecentStoreOld устареет
|
|
||||||
{
|
|
||||||
await this.convertFileToDiskPrefix();
|
|
||||||
if (this.recentRev > 10)
|
|
||||||
await bmRecentStoreOld.clear();
|
|
||||||
}
|
|
||||||
} else {//TODO: убрать после 06.2021, когда bmRecentStoreOld устареет
|
|
||||||
this.recentLast = await bmRecentStoreOld.getItem('recent-last');
|
|
||||||
if (this.recentLast) {
|
|
||||||
this.recent[this.recentLast.key] = this.recentLast;
|
|
||||||
const meta = await bmMetaStore.getItem(`bmMeta-${this.recentLast.key}`);
|
|
||||||
if (_.isObject(meta)) {
|
|
||||||
this.books[meta.key] = meta;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let key = null;
|
|
||||||
const len = await bmRecentStoreOld.length();
|
|
||||||
for (let i = len - 1; i >= 0; i--) {
|
|
||||||
key = await bmRecentStoreOld.key(i);
|
|
||||||
if (key) {
|
|
||||||
let r = await bmRecentStoreOld.getItem(key);
|
|
||||||
if (_.isObject(r) && r.key) {
|
|
||||||
this.recent[r.key] = r;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
await bmRecentStoreOld.removeItem(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//размножение для дебага
|
|
||||||
/*if (key) {
|
|
||||||
for (let i = 0; i < 1000; i++) {
|
|
||||||
const k = this.keyFromUrl(i.toString());
|
|
||||||
this.recent[k] = Object.assign({}, _.cloneDeep(this.recent[key]), {key: k, touchTime: Date.now() - 1000000, url: utils.randomHexString(300)});
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
await bmRecentStoreNew.setItem('recent', this.recent);
|
|
||||||
this.recentRev = 1;
|
|
||||||
await bmRecentStoreNew.setItem('rev', this.recentRev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.recentChanged = true;
|
this.recentChanged = true;
|
||||||
@@ -374,7 +332,7 @@ class BookManager {
|
|||||||
//-- recent --------------------------------------------------------------
|
//-- recent --------------------------------------------------------------
|
||||||
async recentSetItem(item = null, skipCheck = false) {
|
async recentSetItem(item = null, skipCheck = false) {
|
||||||
const rev = await bmRecentStoreNew.getItem('rev');
|
const rev = await bmRecentStoreNew.getItem('rev');
|
||||||
if (rev != this.recentRev && !skipCheck) {
|
if (rev != this.recentRev && !skipCheck) {//если изменение произошло в другой вкладке барузера
|
||||||
const newRecent = await bmRecentStoreNew.getItem('recent');
|
const newRecent = await bmRecentStoreNew.getItem('recent');
|
||||||
Object.assign(this.recent, newRecent);
|
Object.assign(this.recent, newRecent);
|
||||||
this.recentItem = await bmRecentStoreNew.getItem('recent-item');
|
this.recentItem = await bmRecentStoreNew.getItem('recent-item');
|
||||||
@@ -455,33 +413,6 @@ class BookManager {
|
|||||||
return isDel;
|
return isDel;
|
||||||
}
|
}
|
||||||
|
|
||||||
async convertFileToDiskPrefix() {
|
|
||||||
let isConverted = false;
|
|
||||||
|
|
||||||
const newRecent = {};
|
|
||||||
for (let key of Object.keys(this.recent)) {
|
|
||||||
let newKey = key;
|
|
||||||
let newUrl = this.recent[key].url;
|
|
||||||
|
|
||||||
if (newKey.indexOf('66696c65') == 0) {
|
|
||||||
newKey = newKey.replace(/^66696c65/, '6469736b');
|
|
||||||
if (newUrl)
|
|
||||||
newUrl = newUrl.replace(/^file/, 'disk');
|
|
||||||
isConverted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
newRecent[newKey] = this.recent[key];
|
|
||||||
newRecent[newKey].key = newKey;
|
|
||||||
if (newUrl)
|
|
||||||
newRecent[newKey].url = newUrl;
|
|
||||||
}
|
|
||||||
if (isConverted) {
|
|
||||||
this.recent = newRecent;
|
|
||||||
await this.recentSetItem(null, true);
|
|
||||||
}
|
|
||||||
return isConverted;
|
|
||||||
}
|
|
||||||
|
|
||||||
mostRecentBook() {
|
mostRecentBook() {
|
||||||
if (this.recentLastKey) {
|
if (this.recentLastKey) {
|
||||||
return this.recent[this.recentLastKey];
|
return this.recent[this.recentLastKey];
|
||||||
|
|||||||
Reference in New Issue
Block a user