BugFix Loading one thread after another crashed the app

pull/167/head
Vitor Pamplona 2023-02-24 17:23:17 -05:00
rodzic 951a4be615
commit 3cdc77a277
3 zmienionych plików z 9 dodań i 2 usunięć

Wyświetl plik

@ -50,6 +50,10 @@ abstract class FeedViewModel(val localFilter: FeedFilter<Note>): ViewModel() {
return localFilter.loadTop()
}
fun clearFeed() {
_feedContent.update { FeedState.Loading }
}
fun refresh() {
val scope = CoroutineScope(Job() + Dispatchers.Default)
scope.launch {

Wyświetl plik

@ -80,7 +80,9 @@ fun ThreadFeedView(noteId: String, viewModel: FeedViewModel, accountViewModel: A
is FeedState.Loaded -> {
LaunchedEffect(noteId) {
val noteForPosition = state.feed.value.filter { it.idHex == noteId}.firstOrNull()
listState.animateScrollToItem(state.feed.value.indexOf(noteForPosition), 0)
val position = state.feed.value.indexOf(noteForPosition)
if (position > 0)
listState.animateScrollToItem(position, 0)
}
LazyColumn(

Wyświetl plik

@ -28,7 +28,8 @@ fun ThreadScreen(noteId: String?, accountViewModel: AccountViewModel, navControl
if (account != null && noteId != null) {
val feedViewModel: NostrThreadFeedViewModel = viewModel()
LaunchedEffect(Unit) {
LaunchedEffect(noteId) {
feedViewModel.clearFeed()
ThreadFeedFilter.loadThread(noteId)
NostrThreadDataSource.loadThread(noteId)
feedViewModel.invalidateData()