Improves blinking when loading a thread.

This commit is contained in:
Vitor Pamplona
2023-08-25 13:01:08 -04:00
parent 017df9845d
commit 5328740bff
2 changed files with 8 additions and 5 deletions
@@ -36,8 +36,10 @@ object NostrThreadDataSource : NostrDataSource("SingleThreadFeed") {
} }
fun loadThread(noteId: String?) { fun loadThread(noteId: String?) {
eventToWatch = noteId if (eventToWatch != noteId) {
eventToWatch = noteId
invalidateFilters() invalidateFilters()
}
} }
} }
@@ -26,9 +26,10 @@ fun ThreadScreen(noteId: String?, accountViewModel: AccountViewModel, nav: (Stri
factory = NostrThreadFeedViewModel.Factory(noteId) factory = NostrThreadFeedViewModel.Factory(noteId)
) )
NostrThreadDataSource.loadThread(noteId)
LaunchedEffect(noteId) { LaunchedEffect(noteId) {
NostrThreadDataSource.loadThread(noteId) feedViewModel.invalidateData(true)
feedViewModel.invalidateData()
} }
DisposableEffect(accountViewModel) { DisposableEffect(accountViewModel) {
@@ -37,7 +38,7 @@ fun ThreadScreen(noteId: String?, accountViewModel: AccountViewModel, nav: (Stri
println("Thread Start") println("Thread Start")
NostrThreadDataSource.loadThread(noteId) NostrThreadDataSource.loadThread(noteId)
NostrThreadDataSource.start() NostrThreadDataSource.start()
feedViewModel.invalidateData() feedViewModel.invalidateData(true)
} }
if (event == Lifecycle.Event.ON_PAUSE) { if (event == Lifecycle.Event.ON_PAUSE) {
println("Thread Stop") println("Thread Stop")