From e40d3dd64dfd218b0320c1f0b1c6e78dc0d48a9d Mon Sep 17 00:00:00 2001 From: mikiher Date: Thu, 25 Jul 2024 09:40:18 +0300 Subject: [PATCH] Simplify ItemSearchCard component --- client/components/cards/ItemSearchCard.vue | 34 +++---------------- client/components/controls/GlobalSearch.vue | 4 +-- .../utils/queries/libraryItemsBookFilters.js | 22 ++---------- .../queries/libraryItemsPodcastFilters.js | 22 ++---------- 4 files changed, 12 insertions(+), 70 deletions(-) diff --git a/client/components/cards/ItemSearchCard.vue b/client/components/cards/ItemSearchCard.vue index bfcac8f0..ca74f1b7 100644 --- a/client/components/cards/ItemSearchCard.vue +++ b/client/components/cards/ItemSearchCard.vue @@ -2,15 +2,9 @@
-

{{ title }}

-

- -

- -

{{ $getString('LabelByAuthor', [authorName]) }}

-

- -

+

{{ title }}

+

{{ subtitle }}

+

{{ $getString('LabelByAuthor', [authorName]) }}

@@ -21,10 +15,7 @@ export default { libraryItem: { type: Object, default: () => {} - }, - search: String, - matchKey: String, - matchText: String + } }, data() { return {} @@ -58,23 +49,6 @@ export default { authorName() { if (this.isPodcast) return this.mediaMetadata.author || 'Unknown' return this.mediaMetadata.authorName || 'Unknown' - }, - matchHtml() { - if (!this.matchText || !this.search) return '' - - // This used to highlight the part of the search found - // but with removing commas periods etc this is no longer plausible - const html = this.matchText - - if (this.matchKey === 'episode') return `

${this.$strings.LabelEpisode}: ${html}

` - if (this.matchKey === 'tags') return `

${this.$strings.LabelTags}: ${html}

` - if (this.matchKey === 'subtitle') return `

${html}

` - if (this.matchKey === 'authors') this.$getString('LabelByAuthor', [html]) - if (this.matchKey === 'isbn') return `

ISBN: ${html}

` - if (this.matchKey === 'asin') return `

ASIN: ${html}

` - if (this.matchKey === 'series') return `

${this.$strings.LabelSeries}: ${html}

` - if (this.matchKey === 'narrators') return `

${this.$strings.LabelNarrator}: ${html}

` - return `${html}` } }, methods: {}, diff --git a/client/components/controls/GlobalSearch.vue b/client/components/controls/GlobalSearch.vue index 65e66927..3c2c6039 100644 --- a/client/components/controls/GlobalSearch.vue +++ b/client/components/controls/GlobalSearch.vue @@ -25,7 +25,7 @@ @@ -34,7 +34,7 @@ diff --git a/server/utils/queries/libraryItemsBookFilters.js b/server/utils/queries/libraryItemsBookFilters.js index f81aef5b..0af86730 100644 --- a/server/utils/queries/libraryItemsBookFilters.js +++ b/server/utils/queries/libraryItemsBookFilters.js @@ -1038,25 +1038,9 @@ module.exports = { const libraryItem = book.libraryItem delete book.libraryItem libraryItem.media = book - - let matchText = null - let matchKey = null - for (const key of ['title', 'subtitle', 'asin', 'isbn']) { - const valueToLower = asciiOnlyToLowerCase(book[key]) - if (valueToLower.includes(query)) { - matchText = book[key] - matchKey = key - break - } - } - - if (matchKey) { - itemMatches.push({ - matchText, - matchKey, - libraryItem: Database.libraryItemModel.getOldLibraryItem(libraryItem).toJSONExpanded() - }) - } + itemMatches.push({ + libraryItem: Database.libraryItemModel.getOldLibraryItem(libraryItem).toJSONExpanded() + }) } // Search narrators diff --git a/server/utils/queries/libraryItemsPodcastFilters.js b/server/utils/queries/libraryItemsPodcastFilters.js index 3fb29761..545ca8a6 100644 --- a/server/utils/queries/libraryItemsPodcastFilters.js +++ b/server/utils/queries/libraryItemsPodcastFilters.js @@ -361,25 +361,9 @@ module.exports = { const libraryItem = podcast.libraryItem delete podcast.libraryItem libraryItem.media = podcast - - let matchText = null - let matchKey = null - for (const key of ['title', 'author', 'itunesId', 'itunesArtistId']) { - const valueToLower = asciiOnlyToLowerCase(podcast[key]) - if (valueToLower.includes(query)) { - matchText = podcast[key] - matchKey = key - break - } - } - - if (matchKey) { - itemMatches.push({ - matchText, - matchKey, - libraryItem: Database.libraryItemModel.getOldLibraryItem(libraryItem).toJSONExpanded() - }) - } + itemMatches.push({ + libraryItem: Database.libraryItemModel.getOldLibraryItem(libraryItem).toJSONExpanded() + }) } // Search tags