mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 18:06:53 +01:00
Initialize NostrUserListVM at LoggedInPage level, to reuse it at different places(in prep for other UI changes).
This commit is contained in:
@@ -79,6 +79,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.hashtag.HashtagScreen
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.HomeScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.HomeScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.ShortNotePostScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.ShortNotePostScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.ListsScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.ListsScreen
|
||||||
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.NostrUserListFeedViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.followsets.FollowSetScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.followsets.FollowSetScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.NotificationScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.NotificationScreen
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.publicMessages.NewPublicMessageScreen
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.publicMessages.NewPublicMessageScreen
|
||||||
@@ -109,6 +110,7 @@ fun AppNavigation(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
accountStateViewModel: AccountStateViewModel,
|
accountStateViewModel: AccountStateViewModel,
|
||||||
sharedPreferencesViewModel: SharedPreferencesViewModel,
|
sharedPreferencesViewModel: SharedPreferencesViewModel,
|
||||||
|
listsViewModel: NostrUserListFeedViewModel,
|
||||||
) {
|
) {
|
||||||
val nav = rememberNav()
|
val nav = rememberNav()
|
||||||
|
|
||||||
@@ -125,9 +127,9 @@ fun AppNavigation(
|
|||||||
composable<Route.Discover> { DiscoverScreen(accountViewModel, nav) }
|
composable<Route.Discover> { DiscoverScreen(accountViewModel, nav) }
|
||||||
composable<Route.Notification> { NotificationScreen(sharedPreferencesViewModel, accountViewModel, nav) }
|
composable<Route.Notification> { NotificationScreen(sharedPreferencesViewModel, accountViewModel, nav) }
|
||||||
|
|
||||||
composableFromEnd<Route.Lists> { ListsScreen(accountViewModel, nav) }
|
composableFromEnd<Route.Lists> { ListsScreen(accountViewModel, listsViewModel, nav) }
|
||||||
composableArgs<Route.FollowSetRoute> {
|
composableArgs<Route.FollowSetRoute> {
|
||||||
FollowSetScreen(it.setIdentifier, accountViewModel, nav)
|
FollowSetScreen(it.setIdentifier, accountViewModel, listsViewModel, nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
composable<Route.EditProfile> { NewUserMetadataScreen(nav, accountViewModel) }
|
composable<Route.EditProfile> { NewUserMetadataScreen(nav, accountViewModel) }
|
||||||
@@ -144,7 +146,7 @@ fun AppNavigation(
|
|||||||
composableFromEndArgs<Route.EditMediaServers> { AllMediaServersScreen(accountViewModel, nav) }
|
composableFromEndArgs<Route.EditMediaServers> { AllMediaServersScreen(accountViewModel, nav) }
|
||||||
|
|
||||||
composableFromEndArgs<Route.ContentDiscovery> { DvmContentDiscoveryScreen(it.id, accountViewModel, nav) }
|
composableFromEndArgs<Route.ContentDiscovery> { DvmContentDiscoveryScreen(it.id, accountViewModel, nav) }
|
||||||
composableFromEndArgs<Route.Profile> { ProfileScreen(it.id, accountViewModel, nav) }
|
composableFromEndArgs<Route.Profile> { ProfileScreen(it.id, accountViewModel, listsViewModel, nav) }
|
||||||
composableFromEndArgs<Route.Note> { ThreadScreen(it.id, accountViewModel, nav) }
|
composableFromEndArgs<Route.Note> { ThreadScreen(it.id, accountViewModel, nav) }
|
||||||
composableFromEndArgs<Route.Hashtag> { HashtagScreen(it, accountViewModel, nav) }
|
composableFromEndArgs<Route.Hashtag> { HashtagScreen(it, accountViewModel, nav) }
|
||||||
composableFromEndArgs<Route.Geohash> { GeoHashScreen(it, accountViewModel, nav) }
|
composableFromEndArgs<Route.Geohash> { GeoHashScreen(it, accountViewModel, nav) }
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import com.vitorpamplona.amethyst.ui.screen.SharedPreferencesViewModel
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.rooms.datasource.ChatroomListFilterAssemblerSubscription
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.rooms.datasource.ChatroomListFilterAssemblerSubscription
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.datasource.DiscoveryFilterAssemblerSubscription
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.datasource.DiscoveryFilterAssemblerSubscription
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.HomeFilterAssemblerSubscription
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.HomeFilterAssemblerSubscription
|
||||||
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.NostrUserListFeedViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.VideoFilterAssemblerSubscription
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.VideoFilterAssemblerSubscription
|
||||||
import com.vitorpamplona.quartz.nip55AndroidSigner.client.IActivityLauncher
|
import com.vitorpamplona.quartz.nip55AndroidSigner.client.IActivityLauncher
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -75,6 +76,12 @@ fun LoggedInPage(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val listsViewModel: NostrUserListFeedViewModel =
|
||||||
|
viewModel(
|
||||||
|
key = "NostrUserListFeedViewModel",
|
||||||
|
factory = NostrUserListFeedViewModel.Factory(accountViewModel.account),
|
||||||
|
)
|
||||||
|
|
||||||
accountViewModel.firstRoute = route
|
accountViewModel.firstRoute = route
|
||||||
|
|
||||||
// Adds this account to the authentication procedures for relays.
|
// Adds this account to the authentication procedures for relays.
|
||||||
@@ -111,6 +118,7 @@ fun LoggedInPage(
|
|||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
accountStateViewModel = accountStateViewModel,
|
accountStateViewModel = accountStateViewModel,
|
||||||
sharedPreferencesViewModel = sharedPreferencesViewModel,
|
sharedPreferencesViewModel = sharedPreferencesViewModel,
|
||||||
|
listsViewModel = listsViewModel,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ import androidx.lifecycle.Lifecycle
|
|||||||
import androidx.lifecycle.LifecycleEventObserver
|
import androidx.lifecycle.LifecycleEventObserver
|
||||||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold
|
import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
||||||
@@ -73,15 +72,9 @@ import kotlinx.coroutines.launch
|
|||||||
@Composable
|
@Composable
|
||||||
fun ListsScreen(
|
fun ListsScreen(
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
followSetsViewModel: NostrUserListFeedViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
val followSetsViewModel: NostrUserListFeedViewModel =
|
|
||||||
viewModel(
|
|
||||||
key = "NostrUserListFeedViewModel",
|
|
||||||
factory = NostrUserListFeedViewModel.Factory(accountViewModel.account),
|
|
||||||
)
|
|
||||||
|
|
||||||
val currentCoroutineScope = rememberCoroutineScope()
|
|
||||||
val lifeCycleOwner = LocalLifecycleOwner.current
|
val lifeCycleOwner = LocalLifecycleOwner.current
|
||||||
|
|
||||||
DisposableEffect(lifeCycleOwner) {
|
DisposableEffect(lifeCycleOwner) {
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ import androidx.compose.ui.text.font.FontWeight
|
|||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.ui.components.ClickableBox
|
import com.vitorpamplona.amethyst.ui.components.ClickableBox
|
||||||
@@ -84,14 +83,9 @@ import kotlinx.coroutines.launch
|
|||||||
fun FollowSetScreen(
|
fun FollowSetScreen(
|
||||||
selectedSetIdentifier: String,
|
selectedSetIdentifier: String,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
followSetViewModel: NostrUserListFeedViewModel,
|
||||||
navigator: INav,
|
navigator: INav,
|
||||||
) {
|
) {
|
||||||
val followSetViewModel: NostrUserListFeedViewModel =
|
|
||||||
viewModel(
|
|
||||||
key = "NostrUserListFeedViewModel",
|
|
||||||
factory = NostrUserListFeedViewModel.Factory(accountViewModel.account),
|
|
||||||
)
|
|
||||||
|
|
||||||
val followSetState by followSetViewModel.feedContent.collectAsState()
|
val followSetState by followSetViewModel.feedContent.collectAsState()
|
||||||
val uiScope = rememberCoroutineScope()
|
val uiScope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ import kotlinx.coroutines.launch
|
|||||||
fun ProfileScreen(
|
fun ProfileScreen(
|
||||||
userId: String?,
|
userId: String?,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
nostrListsViewModel: NostrUserListFeedViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
if (userId == null) return
|
if (userId == null) return
|
||||||
@@ -123,6 +124,7 @@ fun ProfileScreen(
|
|||||||
PrepareViewModels(
|
PrepareViewModels(
|
||||||
baseUser = it,
|
baseUser = it,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
|
nostrListsViewModel = nostrListsViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -132,6 +134,7 @@ fun ProfileScreen(
|
|||||||
fun PrepareViewModels(
|
fun PrepareViewModels(
|
||||||
baseUser: User,
|
baseUser: User,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
nostrListsViewModel: NostrUserListFeedViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
val followsFeedViewModel: UserProfileFollowsUserFeedViewModel =
|
val followsFeedViewModel: UserProfileFollowsUserFeedViewModel =
|
||||||
@@ -228,15 +231,6 @@ fun PrepareViewModels(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
val followSetsViewModel: NostrUserListFeedViewModel =
|
|
||||||
viewModel(
|
|
||||||
key = "NostrUserListFeedViewModel",
|
|
||||||
factory =
|
|
||||||
NostrUserListFeedViewModel.Factory(
|
|
||||||
accountViewModel.account,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
ProfileScreen(
|
ProfileScreen(
|
||||||
baseUser = baseUser,
|
baseUser = baseUser,
|
||||||
threadsViewModel,
|
threadsViewModel,
|
||||||
@@ -249,7 +243,7 @@ fun PrepareViewModels(
|
|||||||
bookmarksFeedViewModel,
|
bookmarksFeedViewModel,
|
||||||
galleryFeedViewModel,
|
galleryFeedViewModel,
|
||||||
reportsFeedViewModel,
|
reportsFeedViewModel,
|
||||||
followSetsViewModel,
|
nostrListsViewModel,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user