From f132cdfbdf9f2370a0b735ed14f3194038e9efff Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 7 Dec 2022 17:09:58 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=20=D1=80=D0=B0=D1=81=D1=88=D0=B8=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D0=BC=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Search/BaseList.js | 9 ++++++--- server/core/DbSearcher.js | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/client/components/Search/BaseList.js b/client/components/Search/BaseList.js index 376968a..dee8119 100644 --- a/client/components/Search/BaseList.js +++ b/client/components/Search/BaseList.js @@ -113,16 +113,19 @@ export default class BaseList { } selectAuthor(author) { - this.search.author = `=${author}`; + const search = (this.isExtendedSearch ? this.extSearch : this.search); + search.author = `=${author}`; this.scrollToTop(); } selectSeries(series) { - this.search.series = `=${series}`; + const search = (this.isExtendedSearch ? this.extSearch : this.search); + search.series = `=${series}`; } selectTitle(title) { - this.search.title = `=${title}`; + const search = (this.isExtendedSearch ? this.extSearch : this.search); + search.title = `=${title}`; } async download(book, action) { diff --git a/server/core/DbSearcher.js b/server/core/DbSearcher.js index 8ab6a43..143256e 100644 --- a/server/core/DbSearcher.js +++ b/server/core/DbSearcher.js @@ -608,10 +608,23 @@ class DbSearcher { for (const id of @all()) { const row = @unsafeRow(id); if (checkBook(row)) - result.push(row.id); + result.push(row); } - return new Uint32Array(result); + result.sort((a, b) => { + let cmp = a.author.localeCompare(b.author); + if (cmp === 0 && (a.series || b.series)) { + cmp = (a.series && b.series ? a.series.localeCompare(b.series) : (a.series ? -1 : 1)); + } + if (cmp === 0) + cmp = a.serno - b.serno; + if (cmp === 0) + cmp = a.title.localeCompare(b.title); + + return cmp; + }); + + return new Uint32Array(result.map(row => row.id)); ` });