Increasing Delays to update lists to 5 seconds while making sure it refreshes quickly when the user switches the tab.

This commit is contained in:
Vitor Pamplona
2023-02-14 16:02:38 -05:00
parent 90bdeffc52
commit a050236d6a
7 changed files with 10 additions and 6 deletions
@@ -125,7 +125,7 @@ class CardFeedViewModel(val dataSource: NostrDataSource<Note>): ViewModel() {
handlerWaiting.set(true)
val scope = CoroutineScope(Job() + Dispatchers.Default)
scope.launch {
delay(100)
delay(5000)
refresh()
handlerWaiting.set(false)
}
@@ -78,7 +78,6 @@ abstract class FeedViewModel(val dataSource: NostrDataSource<Note>): ViewModel()
}
fun refresh() {
println("AAA Refresh")
val scope = CoroutineScope(Job() + Dispatchers.Default)
scope.launch {
refreshSuspended()
@@ -123,7 +122,7 @@ abstract class FeedViewModel(val dataSource: NostrDataSource<Note>): ViewModel()
handlerWaiting.set(true)
val scope = CoroutineScope(Job() + Dispatchers.Default)
scope.launch {
delay(1000)
delay(5000)
refresh()
handlerWaiting.set(false)
}
@@ -87,7 +87,7 @@ open class UserFeedViewModel(val dataSource: NostrDataSource<User>): ViewModel()
handlerWaiting.set(true)
val scope = CoroutineScope(Job() + Dispatchers.Default)
scope.launch {
delay(1000)
delay(5000)
refresh()
handlerWaiting.set(false)
}
@@ -131,6 +131,7 @@ fun ChannelScreen(channelId: String?, accountViewModel: AccountViewModel, accoun
onPost = {
account.sendChannelMeesage(newPost.value.text, channel.idHex, null, null)
newPost.value = TextFieldValue("")
feedViewModel.refresh() // Don't wait a full second before updating
},
newPost.value.text.isNotBlank(),
modifier = Modifier.padding(end = 10.dp)
@@ -75,7 +75,8 @@ fun TabKnown(accountViewModel: AccountViewModel, navController: NavController) {
val feedViewModel: NostrChatroomListKnownFeedViewModel = viewModel()
LaunchedEffect(Unit) {
feedViewModel.refresh()
feedViewModel.hardRefresh() // refresh filters
feedViewModel.refresh() // refresh view
}
Column(Modifier.fillMaxHeight()) {
@@ -92,7 +93,8 @@ fun TabNew(accountViewModel: AccountViewModel, navController: NavController) {
val feedViewModel: NostrChatroomListNewFeedViewModel = viewModel()
LaunchedEffect(Unit) {
feedViewModel.refresh()
feedViewModel.hardRefresh() // refresh filters
feedViewModel.refresh() // refresh view
}
Column(Modifier.fillMaxHeight()) {
@@ -110,6 +110,7 @@ fun ChatroomScreen(userId: String?, accountViewModel: AccountViewModel, navContr
onPost = {
account.sendPrivateMeesage(newPost.value.text, userId)
newPost.value = TextFieldValue("")
feedViewModel.refresh() // Don't wait a full second before updating
},
newPost.value.text.isNotBlank(),
modifier = Modifier.padding(end = 10.dp)
@@ -34,6 +34,7 @@ fun HomeScreen(accountViewModel: AccountViewModel, navController: NavController)
LaunchedEffect(Unit) {
feedViewModel.refresh()
feedViewModelReplies.refresh()
}
Column(Modifier.fillMaxHeight()) {