mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-09 11:38:40 +01:00
fix: set community in post creation (#517)
This commit is contained in:
parent
77d7d9c697
commit
5192e4cce6
@ -53,6 +53,7 @@ import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.KeyboardCapitalization
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextDecoration
|
||||
import androidx.compose.ui.unit.dp
|
||||
import cafe.adriel.voyager.core.screen.Screen
|
||||
@ -161,7 +162,7 @@ class CreatePostScreen(
|
||||
|
||||
LaunchedEffect(model, communityId) {
|
||||
communityId?.also { communityId ->
|
||||
CreatePostMviModel.Intent.SetCommunity(CommunityModel(id = communityId))
|
||||
model.reduce(CreatePostMviModel.Intent.SetCommunity(CommunityModel(id = communityId)))
|
||||
}
|
||||
}
|
||||
LaunchedEffect(model) {
|
||||
@ -500,22 +501,6 @@ class CreatePostScreen(
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
}
|
||||
if (uiState.currentUser.isNotEmpty()) {
|
||||
Text(
|
||||
text = buildString {
|
||||
append(stringResource(MR.strings.post_reply_source_account))
|
||||
append(" ")
|
||||
append(uiState.currentUser)
|
||||
if (uiState.currentInstance.isNotEmpty()) {
|
||||
append("@")
|
||||
append(uiState.currentInstance)
|
||||
}
|
||||
},
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
textDecoration = TextDecoration.Underline,
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
@ -538,6 +523,27 @@ class CreatePostScreen(
|
||||
showScores = uiState.showScores,
|
||||
)
|
||||
}
|
||||
|
||||
if (uiState.currentUser.isNotEmpty()) {
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = Spacing.m),
|
||||
text = buildString {
|
||||
append(stringResource(MR.strings.post_reply_source_account))
|
||||
append(" ")
|
||||
append(uiState.currentUser)
|
||||
if (uiState.currentInstance.isNotEmpty()) {
|
||||
append("@")
|
||||
append(uiState.currentInstance)
|
||||
}
|
||||
},
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
textDecoration = TextDecoration.Underline,
|
||||
textAlign = TextAlign.End,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,8 @@ class CreatePostViewModel(
|
||||
}
|
||||
|
||||
private fun submit(body: String) {
|
||||
if (uiState.value.loading) {
|
||||
val currentState = uiState.value
|
||||
if (currentState.loading) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -176,41 +177,33 @@ class CreatePostViewModel(
|
||||
)
|
||||
}
|
||||
|
||||
val communityId = uiState.value.communityId
|
||||
val title = uiState.value.title
|
||||
val url = uiState.value.url.takeIf { it.isNotEmpty() }?.trim()
|
||||
val nsfw = uiState.value.nsfw
|
||||
val languageId = uiState.value.currentLanguageId
|
||||
val communityId = currentState.communityId
|
||||
val title = currentState.title
|
||||
val url = currentState.url.takeIf { it.isNotEmpty() }?.trim()
|
||||
val nsfw = currentState.nsfw
|
||||
val languageId = currentState.currentLanguageId
|
||||
var valid = true
|
||||
if (title.isEmpty()) {
|
||||
updateState {
|
||||
it.copy(
|
||||
titleError = message_missing_field.desc(),
|
||||
)
|
||||
it.copy(titleError = message_missing_field.desc())
|
||||
}
|
||||
valid = false
|
||||
}
|
||||
if (body.isEmpty()) {
|
||||
updateState {
|
||||
it.copy(
|
||||
bodyError = message_missing_field.desc(),
|
||||
)
|
||||
it.copy(bodyError = message_missing_field.desc())
|
||||
}
|
||||
valid = false
|
||||
}
|
||||
if (!url.isNullOrEmpty() && !url.isValidUrl()) {
|
||||
updateState {
|
||||
it.copy(
|
||||
urlError = message_invalid_field.desc(),
|
||||
)
|
||||
it.copy(urlError = message_invalid_field.desc())
|
||||
}
|
||||
valid = false
|
||||
}
|
||||
if (communityId == null) {
|
||||
updateState {
|
||||
it.copy(
|
||||
communityError = message_missing_field.desc(),
|
||||
)
|
||||
it.copy(communityError = message_missing_field.desc())
|
||||
}
|
||||
valid = false
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user