diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index 749c757d..8b68ff03 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -1146,7 +1146,7 @@ class Reader { }); book = Object.assign({}, wasOpened, {data: resp.data}); } catch (e) { - //молчим + this.$root.notify.error('Конвертированный файл не найден на сервере', 'Ошибка загрузки'); } } } @@ -1186,16 +1186,17 @@ class Reader { found = (found ? _.cloneDeep(found) : found); if (found) { - //спрашиваем, надо ли объединить файлы - const askResult = (wasOpened.path == found.path) || - await this.$root.stdDialog.askYesNo(` -Файл с именем "${wasOpened.uploadFileName}" уже есть в загруженных. -
Объединить позицию?`, 'Найдена похожая книга'); - - if (askResult) { - wasOpened.bookPos = found.bookPos; - wasOpened.bookPosSeen = found.bookPosSeen; - wasOpened.sameBookKey = found.sameBookKey; + if (wasOpened.sameBookKey != found.sameBookKey) { + //спрашиваем, надо ли объединить файлы + const askResult = bookManager.keysEqual(found.path, addedBook.path) || + await this.$root.stdDialog.askYesNo(` + Файл с именем "${wasOpened.uploadFileName}" уже есть в загруженных. +
Объединить позицию?`, 'Найдена похожая книга'); + if (askResult) { + wasOpened.bookPos = found.bookPos; + wasOpened.bookPosSeen = found.bookPosSeen; + wasOpened.sameBookKey = found.sameBookKey; + } } } else { wasOpened.sameBookKey = wasOpened.uploadFileName; @@ -1204,6 +1205,9 @@ class Reader { wasOpened.sameBookKey = addedBook.url; } + if (!bookManager.keysEqual(wasOpened.path, addedBook.path)) + delete wasOpened.loadTime; + // добавляем в историю await bookManager.setRecentBook(Object.assign(wasOpened, addedBook)); this.mostRecentBook(); diff --git a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue index d45453b8..a7cdee04 100644 --- a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue +++ b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue @@ -70,15 +70,16 @@ {{ item.desc.author }}
{{ item.desc.title }}
+
-
- {{ item.desc.perc }} -
-
+
{{ item.desc.textLen }}
+
+ {{ item.desc.perc }} +
@@ -285,7 +286,7 @@ class RecentBooksPage { if (book.textLength) { readPart = p/book.textLength; perc = `${(readPart*100).toFixed(2)}%`; - textLen = `${Math.round(book.textLength/1000)}k`; + textLen = `${Math.floor(readPart*book.textLength/1000)}/${Math.floor(book.textLength/1000)}`; } const bt = utils.getBookTitle(book.fb2); diff --git a/client/components/Reader/share/bookManager.js b/client/components/Reader/share/bookManager.js index 5a37cea2..1e232d00 100644 --- a/client/components/Reader/share/bookManager.js +++ b/client/components/Reader/share/bookManager.js @@ -367,6 +367,13 @@ class BookManager { keyFromPath(bookPath) { return path.basename(bookPath); } + + keysEqual(bookPath1, bookPath2) { + if (bookPath1 === undefined || bookPath2 === undefined) + return false; + + return (this.keyFromPath(bookPath1) === this.keyFromPath(bookPath2)); + } //-- recent -------------------------------------------------------------- async recentSetItem(item = null, skipCheck = false) { const rev = await bmRecentStoreNew.getItem('rev'); @@ -506,8 +513,8 @@ class BookManager { for (const key in this.recent) { const book = this.recent[key]; - if (!book.deleted && book.url == url && book.touchTime > max) { - max = book.touchTime; + if (!book.deleted && book.url == url && book.loadTime > max) { + max = book.loadTime; result = book; } } @@ -521,8 +528,8 @@ class BookManager { for (const key in this.recent) { const book = this.recent[key]; - if (!book.deleted && book.sameBookKey == sameKey && book.touchTime > max) { - max = book.touchTime; + if (!book.deleted && book.sameBookKey == sameKey && book.loadTime > max) { + max = book.loadTime; result = book; } }