Fixes the update of the feed after adding an image on stories.
This commit is contained in:
@@ -48,7 +48,7 @@ import kotlinx.coroutines.withContext
|
|||||||
|
|
||||||
@OptIn(ExperimentalPermissionsApi::class)
|
@OptIn(ExperimentalPermissionsApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun NewImageButton(accountViewModel: AccountViewModel, nav: (String) -> Unit) {
|
fun NewImageButton(accountViewModel: AccountViewModel, nav: (String) -> Unit, navScrollToTop: (Route, Boolean) -> Unit) {
|
||||||
var wantsToPost by remember {
|
var wantsToPost by remember {
|
||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
@@ -62,11 +62,9 @@ fun NewImageButton(accountViewModel: AccountViewModel, nav: (String) -> Unit) {
|
|||||||
val postViewModel: NewMediaModel = viewModel()
|
val postViewModel: NewMediaModel = viewModel()
|
||||||
postViewModel.onceUploaded {
|
postViewModel.onceUploaded {
|
||||||
scope.launch(Dispatchers.Default) {
|
scope.launch(Dispatchers.Default) {
|
||||||
// awaits an refresh on the list
|
delay(500)
|
||||||
delay(250)
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
val route = Route.Video.route.replace("{scrollToTop}", "true")
|
navScrollToTop(Route.Video, true)
|
||||||
nav(route)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ fun MainScreen(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
floatingActionButton = {
|
floatingActionButton = {
|
||||||
FloatingButtons(navState, accountViewModel, accountStateViewModel, nav)
|
FloatingButtons(navState, accountViewModel, accountStateViewModel, nav, navBottomRow)
|
||||||
},
|
},
|
||||||
scaffoldState = scaffoldState
|
scaffoldState = scaffoldState
|
||||||
) {
|
) {
|
||||||
@@ -247,7 +247,8 @@ fun FloatingButtons(
|
|||||||
navEntryState: State<NavBackStackEntry?>,
|
navEntryState: State<NavBackStackEntry?>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
accountStateViewModel: AccountStateViewModel,
|
accountStateViewModel: AccountStateViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit,
|
||||||
|
navScrollToTop: (Route, Boolean) -> Unit
|
||||||
) {
|
) {
|
||||||
val accountState by accountStateViewModel.accountContent.collectAsState()
|
val accountState by accountStateViewModel.accountContent.collectAsState()
|
||||||
|
|
||||||
@@ -260,7 +261,7 @@ fun FloatingButtons(
|
|||||||
// Does nothing.
|
// Does nothing.
|
||||||
}
|
}
|
||||||
is AccountState.LoggedIn -> {
|
is AccountState.LoggedIn -> {
|
||||||
WritePermissionButtons(navEntryState, accountViewModel, nav)
|
WritePermissionButtons(navEntryState, accountViewModel, nav, navScrollToTop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,7 +271,8 @@ fun FloatingButtons(
|
|||||||
private fun WritePermissionButtons(
|
private fun WritePermissionButtons(
|
||||||
navEntryState: State<NavBackStackEntry?>,
|
navEntryState: State<NavBackStackEntry?>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit,
|
||||||
|
navScrollToTop: (Route, Boolean) -> Unit
|
||||||
) {
|
) {
|
||||||
val currentRoute by remember(navEntryState.value) {
|
val currentRoute by remember(navEntryState.value) {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
@@ -281,7 +283,7 @@ private fun WritePermissionButtons(
|
|||||||
when (currentRoute) {
|
when (currentRoute) {
|
||||||
Route.Home.base -> NewNoteButton(accountViewModel, nav)
|
Route.Home.base -> NewNoteButton(accountViewModel, nav)
|
||||||
Route.Message.base -> ChannelFabColumn(accountViewModel, nav)
|
Route.Message.base -> ChannelFabColumn(accountViewModel, nav)
|
||||||
Route.Video.base -> NewImageButton(accountViewModel, nav)
|
Route.Video.base -> NewImageButton(accountViewModel, nav, navScrollToTop)
|
||||||
Route.Community.base -> {
|
Route.Community.base -> {
|
||||||
val communityId by remember(navEntryState.value) {
|
val communityId by remember(navEntryState.value) {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
|
|||||||
Reference in New Issue
Block a user