mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 09:07:52 +02:00
BugFix Loading one thread after another crashed the app
This commit is contained in:
@@ -50,6 +50,10 @@ abstract class FeedViewModel(val localFilter: FeedFilter<Note>): ViewModel() {
|
|||||||
return localFilter.loadTop()
|
return localFilter.loadTop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clearFeed() {
|
||||||
|
_feedContent.update { FeedState.Loading }
|
||||||
|
}
|
||||||
|
|
||||||
fun refresh() {
|
fun refresh() {
|
||||||
val scope = CoroutineScope(Job() + Dispatchers.Default)
|
val scope = CoroutineScope(Job() + Dispatchers.Default)
|
||||||
scope.launch {
|
scope.launch {
|
||||||
|
@@ -80,7 +80,9 @@ fun ThreadFeedView(noteId: String, viewModel: FeedViewModel, accountViewModel: A
|
|||||||
is FeedState.Loaded -> {
|
is FeedState.Loaded -> {
|
||||||
LaunchedEffect(noteId) {
|
LaunchedEffect(noteId) {
|
||||||
val noteForPosition = state.feed.value.filter { it.idHex == noteId}.firstOrNull()
|
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(
|
LazyColumn(
|
||||||
|
@@ -28,7 +28,8 @@ fun ThreadScreen(noteId: String?, accountViewModel: AccountViewModel, navControl
|
|||||||
if (account != null && noteId != null) {
|
if (account != null && noteId != null) {
|
||||||
val feedViewModel: NostrThreadFeedViewModel = viewModel()
|
val feedViewModel: NostrThreadFeedViewModel = viewModel()
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(noteId) {
|
||||||
|
feedViewModel.clearFeed()
|
||||||
ThreadFeedFilter.loadThread(noteId)
|
ThreadFeedFilter.loadThread(noteId)
|
||||||
NostrThreadDataSource.loadThread(noteId)
|
NostrThreadDataSource.loadThread(noteId)
|
||||||
feedViewModel.invalidateData()
|
feedViewModel.invalidateData()
|
||||||
|
Reference in New Issue
Block a user