mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-21 18:50:47 +02:00
BugFix Sticky notifications on account change
This commit is contained in:
@@ -40,4 +40,8 @@ object NotificationFeedFilter : FeedFilter<Note>() {
|
||||
.toList()
|
||||
.reversed()
|
||||
}
|
||||
|
||||
fun isDifferentAccount(account: Account): Boolean {
|
||||
return this::account.isInitialized && this.account != account
|
||||
}
|
||||
}
|
||||
|
@@ -53,9 +53,13 @@ fun AppNavigation(
|
||||
GlobalFeedFilter.account = account
|
||||
val searchFeedViewModel: NostrGlobalFeedViewModel = viewModel()
|
||||
|
||||
val restartNotificationList = NotificationFeedFilter.isDifferentAccount(account)
|
||||
|
||||
NotificationFeedFilter.account = account
|
||||
val notifFeedViewModel: NotificationViewModel = viewModel()
|
||||
|
||||
if (restartNotificationList) notifFeedViewModel.clear()
|
||||
|
||||
NavHost(navController, startDestination = Route.Home.route) {
|
||||
Route.Search.let { route ->
|
||||
composable(route.route, route.arguments, content = {
|
||||
|
@@ -160,7 +160,12 @@ open class CardFeedViewModel(val dataSource: FeedFilter<Note>) : ViewModel() {
|
||||
LocalCache.live.observeForever(cacheListener)
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
lastNotes = null
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
clear()
|
||||
LocalCache.live.removeObserver(cacheListener)
|
||||
super.onCleared()
|
||||
}
|
||||
|
Reference in New Issue
Block a user