From 89acde1b90a8ec52f3475e4414619ce867cba0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Mon, 25 Sep 2023 18:47:18 +0000 Subject: [PATCH] filters: Add filter to hashtag search timeline view (#1412) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Applied the content filters to the hashtag search timeline view, to filter out #nsfw-tagged posts on that view if the user has that setting enabled. Testing of the fix ------------------ **PASS** **iOS:** 17.0 (iPhone 14 Pro simulator) **Damus:** This commit **Test steps:** 1. Search for #sauna hashtag 2. Pick one post from results that contains multiple hashtags 3. Locally change nsfw filter in the code to another hashtag (I picked #homestead in this example) (This is to make testing easier) 4. Run app on simulator 5. Disable nsfw filtering 6. Search for the #sauna hashtag 7. Ensure that the post from step 2 is there 8. Turn on nsfw filtering 9. Search for the #sauna hashtag again. Ensure that post from step 2 is no longer visible 10. Switch keyword back to #nsfw in the code. Re-run app 11. Search for the #nsfw hashtag. No posts appear (timeline view is empty). (Not sure if this is the desired behavior, but seems reasonable) 12. Turn off nsfw filtering 13. Search for the #nsfw hashtag again. #nsfw posts should appear. Closes: https://github.com/damus-io/damus/issues/1412 Changelog-Fixed: Apply filters to hashtag search timeline view Signed-off-by: Daniel D’Aquino Reviewed-by: William Casarin Signed-off-by: William Casarin --- damus/Views/SearchView.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/damus/Views/SearchView.swift b/damus/Views/SearchView.swift index d8baf218..eb55cd6a 100644 --- a/damus/Views/SearchView.swift +++ b/damus/Views/SearchView.swift @@ -11,11 +11,16 @@ struct SearchView: View { let appstate: DamusState @ObservedObject var search: SearchModel @Environment(\.dismiss) var dismiss + + var content_filter: (NostrEvent) -> Bool { + let filters = ContentFilters.defaults(damus_state: self.appstate) + return ContentFilters(filters: filters).filter + } let height: CGFloat = 250.0 var body: some View { - TimelineView(events: search.events, loading: $search.loading, damus: appstate, show_friend_icon: true, filter: { _ in true }) { + TimelineView(events: search.events, loading: $search.loading, damus: appstate, show_friend_icon: true, filter: content_filter) { ZStack(alignment: .leading) { DamusBackground(maxHeight: height) .mask(LinearGradient(gradient: Gradient(colors: [.black, .black, .black, .clear]), startPoint: .top, endPoint: .bottom))