mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-23 23:10:58 +02:00
Makes sure it doesn't crash on starting.
This commit is contained in:
parent
c8365439ee
commit
7246a545af
@ -29,7 +29,9 @@ object NostrDiscoveryDataSource : NostrDataSource("DiscoveryFeed") {
|
||||
job?.cancel()
|
||||
job = scope.launch(Dispatchers.IO) {
|
||||
account.liveDiscoveryFollowLists.collect {
|
||||
invalidateFilters()
|
||||
if (this@NostrDiscoveryDataSource::account.isInitialized) {
|
||||
invalidateFilters()
|
||||
}
|
||||
}
|
||||
}
|
||||
super.start()
|
||||
|
@ -35,7 +35,9 @@ object NostrHomeDataSource : NostrDataSource("HomeFeed") {
|
||||
job?.cancel()
|
||||
job = account.scope.launch(Dispatchers.IO) {
|
||||
account.liveHomeFollowLists.collect {
|
||||
invalidateFilters()
|
||||
if (this@NostrHomeDataSource::account.isInitialized) {
|
||||
invalidateFilters()
|
||||
}
|
||||
}
|
||||
}
|
||||
super.start()
|
||||
|
@ -24,7 +24,9 @@ object NostrVideoDataSource : NostrDataSource("VideoFeed") {
|
||||
job?.cancel()
|
||||
job = scope.launch(Dispatchers.IO) {
|
||||
account.liveStoriesFollowLists.collect {
|
||||
invalidateFilters()
|
||||
if (this@NostrVideoDataSource::account.isInitialized) {
|
||||
invalidateFilters()
|
||||
}
|
||||
}
|
||||
}
|
||||
super.start()
|
||||
|
@ -55,7 +55,7 @@ fun HomeScreen(
|
||||
|
||||
WatchAccountForHomeScreen(homeFeedViewModel, repliesFeedViewModel, accountViewModel)
|
||||
|
||||
WatchLifeCycleChanges()
|
||||
WatchLifeCycleChanges(accountViewModel)
|
||||
|
||||
AssembleHomeTabs(homeFeedViewModel, repliesFeedViewModel) { pagerState, tabItems ->
|
||||
AssembleHomePage(pagerState, tabItems, accountViewModel, nav)
|
||||
@ -109,11 +109,12 @@ fun ResolveNIP47(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun WatchLifeCycleChanges() {
|
||||
private fun WatchLifeCycleChanges(accountViewModel: AccountViewModel) {
|
||||
val lifeCycleOwner = LocalLifecycleOwner.current
|
||||
DisposableEffect(lifeCycleOwner) {
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
if (event == Lifecycle.Event.ON_RESUME) {
|
||||
NostrHomeDataSource.account = accountViewModel.account
|
||||
NostrHomeDataSource.invalidateFilters()
|
||||
}
|
||||
}
|
||||
@ -219,6 +220,7 @@ fun WatchAccountForHomeScreen(
|
||||
val homeFollowList by accountViewModel.account.liveHomeFollowLists.collectAsStateWithLifecycle()
|
||||
|
||||
LaunchedEffect(accountViewModel, homeFollowList) {
|
||||
NostrHomeDataSource.account = accountViewModel.account
|
||||
NostrHomeDataSource.invalidateFilters()
|
||||
homeFeedViewModel.checkKeysInvalidateDataAndSendToTop()
|
||||
repliesFeedViewModel.checkKeysInvalidateDataAndSendToTop()
|
||||
|
@ -86,6 +86,7 @@ fun NotificationScreen(
|
||||
DisposableEffect(lifeCycleOwner) {
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
if (event == Lifecycle.Event.ON_RESUME) {
|
||||
NostrAccountDataSource.account = accountViewModel.account
|
||||
NostrAccountDataSource.invalidateFilters()
|
||||
}
|
||||
}
|
||||
@ -144,6 +145,7 @@ fun WatchAccountForNotifications(
|
||||
val listState by accountViewModel.account.liveStoriesFollowLists.collectAsStateWithLifecycle()
|
||||
|
||||
LaunchedEffect(accountViewModel, listState) {
|
||||
NostrAccountDataSource.account = accountViewModel.account
|
||||
NostrAccountDataSource.invalidateFilters()
|
||||
notifFeedViewModel.checkKeysInvalidateDataAndSendToTop()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user