Добавлен запрос на объединение позиций при
обнаружении похожего файла в загруженных
This commit is contained in:
@@ -1090,7 +1090,7 @@ class Reader {
|
|||||||
progress.show();
|
progress.show();
|
||||||
progress.setState({state: 'parse'});
|
progress.setState({state: 'parse'});
|
||||||
|
|
||||||
// есть ли среди недавних
|
// есть ли среди загруженных
|
||||||
let wasOpened = bookManager.findRecentByUrlAndPath(url, opts.path);
|
let wasOpened = bookManager.findRecentByUrlAndPath(url, opts.path);
|
||||||
wasOpened = (wasOpened ? _.cloneDeep(wasOpened) : {});
|
wasOpened = (wasOpened ? _.cloneDeep(wasOpened) : {});
|
||||||
|
|
||||||
@@ -1166,6 +1166,31 @@ class Reader {
|
|||||||
progress.setState({progress: prog});
|
progress.setState({progress: prog});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// sameBookKey
|
||||||
|
if (url.indexOf('disk://') == 0) {
|
||||||
|
//ищем такой файл в загруженных
|
||||||
|
let found = bookManager.findRecentBySameBookKey(wasOpened.uploadFileName);
|
||||||
|
found = (found ? _.cloneDeep(found) : found);
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
//спрашиваем, надо ли объединить файлы
|
||||||
|
const askResult = (wasOpened.path == found.path) ||
|
||||||
|
await this.$root.stdDialog.askYesNo(`
|
||||||
|
Файл с именем "${wasOpened.uploadFileName}" уже есть в загруженных.
|
||||||
|
<br>Объединить позицию?`, 'Найдена похожая книга');
|
||||||
|
|
||||||
|
if (askResult) {
|
||||||
|
wasOpened.bookPos = found.bookPos;
|
||||||
|
wasOpened.bookPosSeen = found.bookPosSeen;
|
||||||
|
wasOpened.sameBookKey = found.sameBookKey;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wasOpened.sameBookKey = wasOpened.uploadFileName;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wasOpened.sameBookKey = addedBook.url;
|
||||||
|
}
|
||||||
|
|
||||||
// добавляем в историю
|
// добавляем в историю
|
||||||
await bookManager.setRecentBook(Object.assign(wasOpened, addedBook));
|
await bookManager.setRecentBook(Object.assign(wasOpened, addedBook));
|
||||||
this.mostRecentBook();
|
this.mostRecentBook();
|
||||||
@@ -1217,7 +1242,7 @@ class Reader {
|
|||||||
|
|
||||||
progress.hide(); this.progressActive = false;
|
progress.hide(); this.progressActive = false;
|
||||||
|
|
||||||
await this.loadBook({url, uploadFileName: opts.file.name, force: true});
|
await this._loadBook({url, uploadFileName: opts.file.name, force: true});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
progress.hide(); this.progressActive = false;
|
progress.hide(); this.progressActive = false;
|
||||||
this.loaderActive = true;
|
this.loaderActive = true;
|
||||||
|
|||||||
@@ -499,8 +499,23 @@ class BookManager {
|
|||||||
|
|
||||||
for (const key in this.recent) {
|
for (const key in this.recent) {
|
||||||
const book = this.recent[key];
|
const book = this.recent[key];
|
||||||
if (!book.deleted && book.url == url && book.addTime > max) {
|
if (!book.deleted && book.url == url && book.touchTime > max) {
|
||||||
max = book.addTime;
|
max = book.touchTime;
|
||||||
|
result = book;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
findRecentBySameBookKey(sameKey) {
|
||||||
|
let max = 0;
|
||||||
|
let result = null;
|
||||||
|
|
||||||
|
for (const key in this.recent) {
|
||||||
|
const book = this.recent[key];
|
||||||
|
if (!book.deleted && book.sameBookKey == sameKey && book.touchTime > max) {
|
||||||
|
max = book.touchTime;
|
||||||
result = book;
|
result = book;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user