mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-29 08:20:51 +00:00
BugFix Loading one thread after another crashed the app
This commit is contained in:
parent
951a4be615
commit
3cdc77a277
@ -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 {
|
||||
|
@ -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(
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user