Clean up the feed

This commit is contained in:
Kgothatso Ngako
2026-06-17 19:02:24 +03:00
parent ccbabf394d
commit d20b69a749
3 changed files with 2878 additions and 59 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -38,6 +38,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import at.torch.compose.ui.view.model.HomeScreenType
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent
import kotlinx.coroutines.launch
@@ -156,7 +157,7 @@ fun HomeScreen(
edgePadding = 10.dp,
selectedTabIndex = homeScreenViewModel.pagerState.currentPage,
) {
_root_ide_package_.at.torch.compose.ui.view.model.HomeScreenType.entries.forEachIndexed { index, destination ->
HomeScreenType.entries.forEachIndexed { index, destination ->
Tab(
selected = homeScreenViewModel.pagerState.currentPage == index,
onClick = {
@@ -182,30 +183,6 @@ fun HomeScreen(
state = homeScreenViewModel.pagerState,
) { pageIndex ->
when (val homeScreenTypeType = _root_ide_package_.at.torch.compose.ui.view.model.HomeScreenType.entries[pageIndex]) {
_root_ide_package_.at.torch.compose.ui.view.model.HomeScreenType.Following, _root_ide_package_.at.torch.compose.ui.view.model.HomeScreenType.Mentions -> {
val feedListViewModel: at.torch.compose.ui.view.model.FeedListViewModel = viewModel(
key = homeScreenTypeType.name,
factory = _root_ide_package_.at.torch.compose.ui.view.model.FeedListViewModel.Companion.factory(
initialFeedListUIState = _root_ide_package_.at.torch.compose.ui.view.state.FeedListUIState.Loading,
synchronizationFilter = homeScreenViewModel.getSynchronizationFilter(
homeScreenTypeType,
profileWithFollowing = homeScreenUIState.profileWithFollowing
),
nostrRepository = nostrRepository
),
)
key(feedListViewModel.feedListUIState) {
feedListViewModel.RenderFeed(
activeUserPublicKey = activeUserPublicKey,
onNavigateToEvent = onNavigateToEvent
)
}
key(true) {
feedListViewModel.initiate()
}
}
_root_ide_package_.at.torch.compose.ui.view.model.HomeScreenType.Messages -> {
val chatRoomListViewModel: at.torch.compose.ui.view.model.ChatRoomListViewModel = viewModel(
key = homeScreenTypeType.name,

View File

@@ -29,7 +29,7 @@ import kotlin.time.Clock
import kotlin.time.Duration.Companion.hours
enum class HomeScreenType {
Following, Mentions, Messages
Messages
}
class HomeViewModel(
@@ -75,39 +75,6 @@ class HomeViewModel(
val now = Clock.System.now()
return when (homeScreenType) {
HomeScreenType.Following -> {
_root_ide_package_.at.torch.compose.database.model.types.SynchronizationFilter(
authors = profileWithFollowing.following.map { it.publicKey }.toTypedArray(),
kinds = arrayOf(
TextNoteEvent.KIND,
RepostEvent.KIND,
),
since = twelveHoursAgo,
until = now,
limit = 50
)
}
HomeScreenType.Mentions -> {
_root_ide_package_.at.torch.compose.database.model.types.SynchronizationFilter(
kinds = arrayOf(
TextNoteEvent.KIND,
RepostEvent.KIND,
ReactionEvent.KIND,
LnZapEvent.KIND,
ContactListEvent.KIND,
AdvertisedRelayListEvent.KIND,
PrivateDmEvent.KIND,
BlossomServersEvent.KIND,
FileServersEvent.KIND
),
tags = mapOf(
Pair("p", listOf(activeUserPublicKey))
),
since = twelveHoursAgo,
until = now,
limit = 50
)
}
HomeScreenType.Messages -> {
_root_ide_package_.at.torch.compose.database.model.types.SynchronizationFilter(
kinds = arrayOf(