diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrDiscoveryDataSource.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrDiscoveryDataSource.kt index 3a6928393..80e40e2f6 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrDiscoveryDataSource.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrDiscoveryDataSource.kt @@ -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() diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrHomeDataSource.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrHomeDataSource.kt index bd95dd06d..de9023f66 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrHomeDataSource.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrHomeDataSource.kt @@ -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() diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrVideoDataSource.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrVideoDataSource.kt index 7b7e0b002..8b7327900 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrVideoDataSource.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrVideoDataSource.kt @@ -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() diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HomeScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HomeScreen.kt index def8f0859..fd883cde1 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HomeScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HomeScreen.kt @@ -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() diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt index 68ab1de80..c4624a814 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt @@ -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() }