Preserves invalidations of DataSources for Home, Videos and Notifications

This commit is contained in:
Vitor Pamplona
2023-05-25 18:34:40 -04:00
parent 1693455d0d
commit 2ed5eae029
3 changed files with 7 additions and 4 deletions
@@ -59,6 +59,7 @@ fun HomeScreen(
LaunchedEffect(accountViewModel, account.defaultHomeFollowList) { LaunchedEffect(accountViewModel, account.defaultHomeFollowList) {
HomeNewThreadFeedFilter.account = account HomeNewThreadFeedFilter.account = account
HomeConversationsFeedFilter.account = account HomeConversationsFeedFilter.account = account
NostrHomeDataSource.invalidateFilters()
} }
if (wantsToAddNip47 != null) { if (wantsToAddNip47 != null) {
@@ -71,6 +72,7 @@ fun HomeScreen(
if (event == Lifecycle.Event.ON_RESUME) { if (event == Lifecycle.Event.ON_RESUME) {
HomeNewThreadFeedFilter.account = account HomeNewThreadFeedFilter.account = account
HomeConversationsFeedFilter.account = account HomeConversationsFeedFilter.account = account
NostrHomeDataSource.invalidateFilters()
} }
} }
@@ -84,7 +86,7 @@ fun HomeScreen(
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
LaunchedEffect(key1 = Unit) { LaunchedEffect(key1 = Unit) {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
NostrHomeDataSource.resetFilters() NostrHomeDataSource.invalidateFilters()
homeFeedViewModel.invalidateData(true) homeFeedViewModel.invalidateData(true)
repliesFeedViewModel.invalidateData(true) repliesFeedViewModel.invalidateData(true)
} }
@@ -70,8 +70,8 @@ fun NotificationScreen(
notifFeedViewModel.clear() notifFeedViewModel.clear()
} }
LaunchedEffect(account.userProfile().pubkeyHex, account.defaultNotificationFollowList) { LaunchedEffect(accountViewModel, account.defaultNotificationFollowList) {
NostrAccountDataSource.resetFilters() NostrAccountDataSource.invalidateFilters()
NotificationFeedFilter.account = account NotificationFeedFilter.account = account
} }
@@ -79,8 +79,8 @@ fun NotificationScreen(
DisposableEffect(accountViewModel) { DisposableEffect(accountViewModel) {
val observer = LifecycleEventObserver { _, event -> val observer = LifecycleEventObserver { _, event ->
if (event == Lifecycle.Event.ON_RESUME) { if (event == Lifecycle.Event.ON_RESUME) {
NostrAccountDataSource.invalidateFilters()
NotificationFeedFilter.account = account NotificationFeedFilter.account = account
notifFeedViewModel.invalidateData(true)
} }
} }
@@ -123,6 +123,7 @@ fun VideoScreen(
LaunchedEffect(accountViewModel, accountState.value?.account?.defaultStoriesFollowList) { LaunchedEffect(accountViewModel, accountState.value?.account?.defaultStoriesFollowList) {
VideoFeedFilter.account = account VideoFeedFilter.account = account
NostrVideoDataSource.account = account NostrVideoDataSource.account = account
NostrVideoDataSource.resetFilters()
} }
DisposableEffect(accountViewModel) { DisposableEffect(accountViewModel) {