From 83dbb5489667f9908dc2f2be79c1577a131bdfc9 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 11 Nov 2022 15:01:14 +0800 Subject: [PATCH 1/3] Allow filtering by author --- packages/api/src/utils/search.ts | 2 ++ packages/api/test/utils/search.test.ts | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/packages/api/src/utils/search.ts b/packages/api/src/utils/search.ts index f09b2b3af..c0244926d 100644 --- a/packages/api/src/utils/search.ts +++ b/packages/api/src/utils/search.ts @@ -280,6 +280,7 @@ export const parseSearchQuery = (query: string | undefined): SearchFilter => { 'sort', 'has', 'saved', + 'author', 'published', 'subscription', 'language', @@ -355,6 +356,7 @@ export const parseSearchQuery = (query: string | undefined): SearchFilter => { break } // match filters + case 'author': case 'title': case 'description': case 'content': { diff --git a/packages/api/test/utils/search.test.ts b/packages/api/test/utils/search.test.ts index a8b505f8c..6d8d8e3de 100644 --- a/packages/api/test/utils/search.test.ts +++ b/packages/api/test/utils/search.test.ts @@ -151,3 +151,11 @@ describe('query with in param set to invalid value', () => { expect(result.inFilter).to.eq(InFilter.INBOX) }) }) + +describe('query with author set', () => { + it('adds author to the match filters', () => { + const result = parseSearchQuery('author:"Omnivore Blog"') + expect(result.matchFilters).to.contain({ field: 'author', value:'omnivore blog' }) + }) +}) + From c5c59c07c06718aafd6aaf8e8013979eaa8463c3 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 11 Nov 2022 15:19:53 +0800 Subject: [PATCH 2/3] Fix test for search field --- packages/api/test/utils/search.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/api/test/utils/search.test.ts b/packages/api/test/utils/search.test.ts index 6d8d8e3de..0ac465053 100644 --- a/packages/api/test/utils/search.test.ts +++ b/packages/api/test/utils/search.test.ts @@ -155,7 +155,8 @@ describe('query with in param set to invalid value', () => { describe('query with author set', () => { it('adds author to the match filters', () => { const result = parseSearchQuery('author:"Omnivore Blog"') - expect(result.matchFilters).to.contain({ field: 'author', value:'omnivore blog' }) + expect(result.matchFilters[0].field).to.equal('author') + expect(result.matchFilters[0].value).to.equal('omnivore blog' }) }) }) From eaaf1c052b5201c89ad361e7e902fe2acc9e8c19 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 11 Nov 2022 15:39:47 +0800 Subject: [PATCH 3/3] Fix typo --- .../Sources/App/Views/Home/HomeFeedViewIOS.swift | 14 ++++++++++---- .../App/Views/WebReader/WebReaderContainer.swift | 4 ++++ .../Sources/Views/FeedItem/GridCard.swift | 4 ---- .../Sources/Views/FeedItem/HomeFeedCardView.swift | 2 ++ packages/api/test/utils/search.test.ts | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 17662712f..2337f76bb 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -335,10 +335,16 @@ import Views Label { Text("Snooze") } icon: { Image.moon } } } - Button( - action: { viewModel.downloadAudio(audioController: audioController, item: item) }, - label: { Label("Download Audio", systemImage: "icloud.and.arrow.down") } - ) + if let author = item.author { + Button( + action: { + viewModel.searchTerm = "author:\"\(author)\"" + }, + label: { + Label(String("More by \(author)"), systemImage: "person") + } + ) + } } .swipeActions(edge: .trailing, allowsFullSwipe: true) { if !item.isArchived { diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift index 3e2b91ab9..dd70144b7 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift @@ -213,6 +213,10 @@ struct WebReaderContainerView: View { }, label: { Label("Reset Read Location", systemImage: "arrow.counterclockwise.circle") } ) + Button( + action: { /* viewModel.downloadAudio(audioController: audioController, item: item) */ }, + label: { Label("Download Audio", systemImage: "icloud.and.arrow.down") } + ) Button( action: share, label: { Label("Share Original", systemImage: "square.and.arrow.up") } diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift index 57e7e86c1..b3ac2411e 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift @@ -71,10 +71,6 @@ public struct GridCard: View { action: { menuActionHandler(.delete) }, label: { Label("Delete", systemImage: "trash") } ) - Button( - action: { menuActionHandler(.downloadAudio) }, - label: { Label("Download Audio", systemImage: "icloud.and.arrow.down") } - ) } } diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift index 4eea19217..42af43b98 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift @@ -76,6 +76,8 @@ public struct FeedCard: View { } Spacer() } + }.introspectScrollView { scrollView in + scrollView.bounces = false } .padding(.top, 0) #if os(macOS) diff --git a/packages/api/test/utils/search.test.ts b/packages/api/test/utils/search.test.ts index 0ac465053..7b0fae299 100644 --- a/packages/api/test/utils/search.test.ts +++ b/packages/api/test/utils/search.test.ts @@ -156,7 +156,7 @@ describe('query with author set', () => { it('adds author to the match filters', () => { const result = parseSearchQuery('author:"Omnivore Blog"') expect(result.matchFilters[0].field).to.equal('author') - expect(result.matchFilters[0].value).to.equal('omnivore blog' }) + expect(result.matchFilters[0].value).to.equal('omnivore blog') }) })