diff --git a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue index 7a9e8474..51812a86 100644 --- a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue +++ b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue @@ -29,6 +29,7 @@ = limit) - break; - - let d = new Date(); - d.setTime(book.touchTime); - const t = utils.formatDate(d).split(' '); - - let readPart = 0; - let perc = ''; - let textLen = ''; - const p = (book.bookPosSeen ? book.bookPosSeen : (book.bookPos ? book.bookPos : 0)); - if (book.textLength) { - readPart = p/book.textLength; - perc = ` [${(readPart*100).toFixed(2)}%]`; - textLen = ` ${Math.round(book.textLength/1000)}k`; - } - - const bt = utils.getBookTitle(book.fb2); - - let title = bt.bookTitle; - title = (title ? `"${title}"`: ''); - const author = (bt.author ? bt.author : (bt.bookTitle ? bt.bookTitle : (book.uploadFileName ? book.uploadFileName : book.url))); - - result.push({ - num, - touchDateTime: book.touchTime, - touchDate: t[0], - touchTime: t[1], - desc: { - author, - title: `${title}${perc}${textLen}`, - }, - readPart, - descString: `${author}${title}${perc}${textLen}`,//для сортировки - url: book.url, - path: book.path, - fullTitle: bt.fullTitle, - key: book.key, - }); - } - - const search = this.search; - result = result.filter(item => { - return !search || - item.touchTime.includes(search) || - item.touchDate.includes(search) || - item.desc.title.toLowerCase().includes(search.toLowerCase()) || - item.desc.author.toLowerCase().includes(search.toLowerCase()) - }); - - this.tableData = result; - this.updating = false; - }*/ - resetSearch() { this.search = ''; this.$refs.input.focus(); @@ -568,6 +502,28 @@ class RecentBooksPage { this.updateTableData(); } + async scrollToActiveBook() { + await this.$nextTick(); + + let activeIndex = -1; + let activeParentIndex = -1; + for (let i = 0; i < this.tableData.length; i++) { + const book = this.tableData[i]; + if (book.active) + activeIndex = i; + if (book.activeParent) + activeParentIndex = i; + + if (activeIndex >= 0 && activeParentIndex >= 0) + break; + } + + const index = (activeIndex >= 0 ? activeIndex : activeParentIndex); + if (index >= 0) { + this.$refs.virtualScroll.scrollTo(index, 'center'); + } + } + close() { this.$emit('recent-books-close'); }