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