feat: Filter home feed by hashtag in-place instead of navigating away
Same approach as relay filtering: selecting a hashtag from the top nav filter now filters the home feed in-place across all tabs, with subscriptions scoped to that hashtag. https://claude.ai/code/session_01PZLLjE7MWh7PPz1woVqmxM
This commit is contained in:
+2
-1
@@ -30,6 +30,7 @@ import com.vitorpamplona.amethyst.model.topNavFeeds.allUserFollows.Kind3UserFoll
|
||||
import com.vitorpamplona.amethyst.model.topNavFeeds.aroundMe.AroundMeFeedFlow
|
||||
import com.vitorpamplona.amethyst.model.topNavFeeds.chess.ChessFeedFlow
|
||||
import com.vitorpamplona.amethyst.model.topNavFeeds.global.GlobalFeedFlow
|
||||
import com.vitorpamplona.amethyst.model.topNavFeeds.hashtag.HashtagFeedFlow
|
||||
import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.NoteFeedFlow
|
||||
import com.vitorpamplona.amethyst.model.topNavFeeds.relay.RelayFeedFlow
|
||||
import com.vitorpamplona.amethyst.model.topNavFeeds.unknown.UnknownFeedFlow
|
||||
@@ -135,7 +136,7 @@ class FeedTopNavFilterState(
|
||||
}
|
||||
|
||||
is TopFilter.Hashtag -> {
|
||||
UnknownFeedFlow(listName)
|
||||
HashtagFeedFlow(listName.tag, followsRelays, proxyRelays)
|
||||
}
|
||||
|
||||
is TopFilter.Relay -> {
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Vitor Pamplona
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.model.topNavFeeds.hashtag
|
||||
|
||||
import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedFlowsType
|
||||
import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavFilter
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.FlowCollector
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
|
||||
class HashtagFeedFlow(
|
||||
val hashtag: String,
|
||||
val outboxRelays: StateFlow<Set<NormalizedRelayUrl>>,
|
||||
val proxyRelays: StateFlow<Set<NormalizedRelayUrl>>,
|
||||
) : IFeedFlowsType {
|
||||
fun buildFilter(relays: Set<NormalizedRelayUrl>) = HashtagTopNavFilter(setOf(hashtag), relays)
|
||||
|
||||
override fun flow(): Flow<IFeedTopNavFilter> =
|
||||
combine(outboxRelays, proxyRelays) { outbox, proxy ->
|
||||
if (proxy.isNotEmpty()) buildFilter(proxy) else buildFilter(outbox)
|
||||
}
|
||||
|
||||
override fun startValue(): HashtagTopNavFilter =
|
||||
if (proxyRelays.value.isNotEmpty()) {
|
||||
buildFilter(proxyRelays.value)
|
||||
} else {
|
||||
buildFilter(outboxRelays.value)
|
||||
}
|
||||
|
||||
override suspend fun startValue(collector: FlowCollector<IFeedTopNavFilter>) {
|
||||
collector.emit(startValue())
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,6 @@ class TopNavFilterState(
|
||||
FeedDefinition(
|
||||
TopFilter.Hashtag(it),
|
||||
HashtagName(it),
|
||||
route = Route.Hashtag(it),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user