BugFix for mixing NIP94 and NIP95 selections

This commit is contained in:
Vitor Pamplona
2023-05-01 20:43:31 -04:00
parent 7d620cd89a
commit 6731ca59cd
@@ -31,6 +31,7 @@ import androidx.compose.ui.window.DialogProperties
import androidx.navigation.NavController import androidx.navigation.NavController
import coil.compose.AsyncImage import coil.compose.AsyncImage
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.Account
import com.vitorpamplona.amethyst.ui.components.* import com.vitorpamplona.amethyst.ui.components.*
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.screen.loggedIn.TextSpinner import com.vitorpamplona.amethyst.ui.screen.loggedIn.TextSpinner
@@ -45,10 +46,9 @@ fun NewMediaView(uri: Uri, onClose: () -> Unit, postViewModel: NewMediaModel, ac
val scroolState = rememberScrollState() val scroolState = rememberScrollState()
val mediaType = resolver.getType(uri) ?: "" LaunchedEffect(uri) {
postViewModel.load(account, uri, mediaType) val mediaType = resolver.getType(uri) ?: ""
postViewModel.load(account, uri, mediaType)
LaunchedEffect(Unit) {
postViewModel.imageUploadingError.collect { error -> postViewModel.imageUploadingError.collect { error ->
Toast.makeText(context, error, Toast.LENGTH_SHORT).show() Toast.makeText(context, error, Toast.LENGTH_SHORT).show()
} }
@@ -101,7 +101,7 @@ fun NewMediaView(uri: Uri, onClose: () -> Unit, postViewModel: NewMediaModel, ac
.fillMaxWidth() .fillMaxWidth()
.verticalScroll(scroolState) .verticalScroll(scroolState)
) { ) {
ImageVideoPost(postViewModel) ImageVideoPost(postViewModel, account)
} }
} }
} }
@@ -110,7 +110,7 @@ fun NewMediaView(uri: Uri, onClose: () -> Unit, postViewModel: NewMediaModel, ac
} }
@Composable @Composable
fun ImageVideoPost(postViewModel: NewMediaModel) { fun ImageVideoPost(postViewModel: NewMediaModel, acc: Account) {
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
val fileServers = listOf( val fileServers = listOf(
@@ -178,7 +178,7 @@ fun ImageVideoPost(postViewModel: NewMediaModel) {
) { ) {
TextSpinner( TextSpinner(
label = stringResource(id = R.string.file_server), label = stringResource(id = R.string.file_server),
placeholder = fileServers.firstOrNull { it.first == postViewModel.selectedServer }?.second ?: fileServers[0].second, placeholder = fileServers.firstOrNull { it.first == acc.defaultFileServer }?.second ?: fileServers[0].second,
options = fileServerOptions, options = fileServerOptions,
explainers = fileServerExplainers, explainers = fileServerExplainers,
onSelect = { onSelect = {