From e877dbe75e20865eef12fa8b08621dba874ac95d Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Mon, 27 Apr 2026 03:01:56 +0200 Subject: [PATCH] Add filters for gallery (pictures/videos) events --- .../ui/composable/SearchResultScreen.kt | 4 ++++ .../widgets/detail/MetadataEventDetail.kt | 4 ++-- .../model/MetadataEventDetailViewModel.kt | 22 ++++++++++++++----- .../ui/view/model/SearchResultViewModel.kt | 19 +++++++++++++--- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/composable/SearchResultScreen.kt b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/composable/SearchResultScreen.kt index d37bbc6a..5fc78dfc 100644 --- a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/composable/SearchResultScreen.kt +++ b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/composable/SearchResultScreen.kt @@ -217,6 +217,9 @@ fun SearchResultScreen( SearchResultType.Videos -> { Text("Videos") } + SearchResultType.Shorts -> { + Text("Shorts") + } } when (val searchResultListUIState = searchViewModel.searchResultListUIState) { @@ -234,6 +237,7 @@ fun SearchResultScreen( } } is SearchResultListUIState.Loaded -> { + // TODO: Handle gallery UI if (searchResultListUIState.localNostrEvents.isEmpty()) { Column( modifier = Modifier.fillMaxWidth(), diff --git a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/composable/widgets/detail/MetadataEventDetail.kt b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/composable/widgets/detail/MetadataEventDetail.kt index f98a54cf..262713e8 100644 --- a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/composable/widgets/detail/MetadataEventDetail.kt +++ b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/composable/widgets/detail/MetadataEventDetail.kt @@ -273,7 +273,7 @@ fun MetadataEventDetail( when (metadataEventDetailType) { MetadataEventDetailType.Posts, MetadataEventDetailType.Replies, MetadataEventDetailType.Articles, MetadataEventDetailType.Zaps, - MetadataEventDetailType.Photos, MetadataEventDetailType.Videos, + MetadataEventDetailType.Photos, MetadataEventDetailType.Shorts, MetadataEventDetailType.Videos, MetadataEventDetailType.Bookmarks, MetadataEventDetailType.Reports, MetadataEventDetailType.Relays -> { val feedListViewModel: FeedListViewModel = viewModel( key = metadataEventDetailType.name, @@ -294,7 +294,7 @@ fun MetadataEventDetail( feedListViewModel.initiate() } } - + // TODO: Support gallery feeds... MetadataEventDetailType.Following -> { val followingListViewModel: FollowingListViewModel = viewModel( key = metadataEventDetailType.name, diff --git a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/view/model/MetadataEventDetailViewModel.kt b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/view/model/MetadataEventDetailViewModel.kt index 71c46fe7..a7f1ee96 100755 --- a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/view/model/MetadataEventDetailViewModel.kt +++ b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/view/model/MetadataEventDetailViewModel.kt @@ -33,12 +33,15 @@ import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip68Picture.PictureEvent +import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent +import com.vitorpamplona.quartz.nip71Video.VideoShortEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.IO import kotlinx.coroutines.launch enum class MetadataEventDetailType { - Posts, Replies, Articles, Followers, Following, Zaps, Photos, Videos, Bookmarks, Reports, Relays + Posts, Replies, Articles, Followers, Following, Zaps, Photos, Shorts, Videos, Bookmarks, Reports, Relays } class MetadataEventDetailViewModel( @@ -164,9 +167,19 @@ class MetadataEventDetailViewModel( publicKey ), kinds = arrayOf( - TextNoteEvent.KIND, + PictureEvent.KIND, + ), + limit = 50 + ) + } + MetadataEventDetailType.Shorts -> { + SynchronizationFilter( + authors = arrayOf( + publicKey + ), + kinds = arrayOf( + VideoShortEvent.KIND, ), - // TODO: filter for tags of pictures... limit = 50 ) } @@ -176,9 +189,8 @@ class MetadataEventDetailViewModel( publicKey ), kinds = arrayOf( - TextNoteEvent.KIND, + VideoNormalEvent.KIND, ), - // TODO: filter for tags of videos... limit = 50 ) } diff --git a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/view/model/SearchResultViewModel.kt b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/view/model/SearchResultViewModel.kt index b4234e21..d36c5e92 100755 --- a/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/view/model/SearchResultViewModel.kt +++ b/composeApp/src/commonMain/kotlin/ac/cord/auxiliary/compose/ui/view/model/SearchResultViewModel.kt @@ -21,12 +21,15 @@ import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip68Picture.PictureEvent +import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent +import com.vitorpamplona.quartz.nip71Video.VideoShortEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.IO import kotlinx.coroutines.launch enum class SearchResultType { - Posts, Articles, Profiles, Photos, Videos + Posts, Articles, Profiles, Photos, Shorts, Videos } class SearchResultViewModel( @@ -87,7 +90,7 @@ class SearchResultViewModel( SearchResultType.Photos -> { SynchronizationFilter( kinds = arrayOf( - TextNoteEvent.KIND, + PictureEvent.KIND, ), // TODO: filter for tags of pictures... search = searchQuery, @@ -97,7 +100,17 @@ class SearchResultViewModel( SearchResultType.Videos -> { SynchronizationFilter( kinds = arrayOf( - TextNoteEvent.KIND, + VideoNormalEvent.KIND, + ), + // TODO: filter for tags of videos... + search = searchQuery, + limit = 50 + ) + } + SearchResultType.Shorts -> { + SynchronizationFilter( + kinds = arrayOf( + VideoShortEvent.KIND, ), // TODO: filter for tags of videos... search = searchQuery,