correct the item where progress spinner happens on
This commit is contained in:
+3
-2
@@ -39,11 +39,12 @@ import com.vitorpamplona.amethyst.ui.stringRes
|
||||
@Composable
|
||||
fun VoicePresetSelector(
|
||||
selectedPreset: VoicePreset,
|
||||
isProcessing: Boolean,
|
||||
processingPreset: VoicePreset?,
|
||||
onPresetSelected: (VoicePreset) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val isProcessing = processingPreset != null
|
||||
|
||||
Row(
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
@@ -51,7 +52,7 @@ fun VoicePresetSelector(
|
||||
) {
|
||||
VoicePreset.entries.forEach { preset ->
|
||||
val isSelected = preset == selectedPreset
|
||||
val isThisProcessing = isProcessing && preset == selectedPreset
|
||||
val isThisProcessing = preset == processingPreset
|
||||
val isEnabled = !isProcessing || preset == VoicePreset.NONE
|
||||
|
||||
FilterChip(
|
||||
|
||||
+1
-1
@@ -409,7 +409,7 @@ private fun NewPostScreenBody(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
VoicePresetSelector(
|
||||
selectedPreset = postViewModel.selectedPreset,
|
||||
isProcessing = postViewModel.isProcessingPreset,
|
||||
processingPreset = postViewModel.processingPreset,
|
||||
onPresetSelected = { postViewModel.selectPreset(it) },
|
||||
)
|
||||
}
|
||||
|
||||
+8
-8
@@ -200,7 +200,7 @@ open class ShortNotePostViewModel :
|
||||
|
||||
// Voice Anonymization
|
||||
var selectedPreset: VoicePreset by mutableStateOf(VoicePreset.NONE)
|
||||
var isProcessingPreset: Boolean by mutableStateOf(false)
|
||||
var processingPreset: VoicePreset? by mutableStateOf(null)
|
||||
var distortedFiles: Map<VoicePreset, AnonymizedResult> by mutableStateOf(emptyMap())
|
||||
private var processingJob: Job? = null
|
||||
|
||||
@@ -829,7 +829,7 @@ open class ShortNotePostViewModel :
|
||||
voiceSelectedServer = null
|
||||
voiceOrchestrator = null
|
||||
selectedPreset = VoicePreset.NONE
|
||||
isProcessingPreset = false
|
||||
processingPreset = null
|
||||
pTags = null
|
||||
|
||||
wantsPoll = false
|
||||
@@ -951,7 +951,7 @@ open class ShortNotePostViewModel :
|
||||
fun canPost(): Boolean {
|
||||
// Voice messages can be posted without text (with either uploaded or pending recording)
|
||||
if (voiceMetadata != null || voiceRecording != null) {
|
||||
return !isUploadingVoice && !isUploadingImage && !isProcessingPreset
|
||||
return !isUploadingVoice && !isUploadingImage && processingPreset == null
|
||||
}
|
||||
|
||||
// Regular text/media posts require text
|
||||
@@ -987,7 +987,7 @@ open class ShortNotePostViewModel :
|
||||
voiceLocalFile = recording.file
|
||||
voiceMetadata = null
|
||||
selectedPreset = VoicePreset.NONE
|
||||
isProcessingPreset = false
|
||||
processingPreset = null
|
||||
}
|
||||
|
||||
fun getVoicePreviewMetadata(): AudioMeta? =
|
||||
@@ -1001,7 +1001,7 @@ open class ShortNotePostViewModel :
|
||||
}
|
||||
|
||||
fun selectPreset(preset: VoicePreset) {
|
||||
if (isProcessingPreset || preset == selectedPreset) return
|
||||
if (processingPreset != null || preset == selectedPreset) return
|
||||
|
||||
if (preset == VoicePreset.NONE) {
|
||||
selectedPreset = preset
|
||||
@@ -1018,7 +1018,7 @@ open class ShortNotePostViewModel :
|
||||
processingJob?.cancel()
|
||||
processingJob =
|
||||
viewModelScope.launch {
|
||||
isProcessingPreset = true
|
||||
processingPreset = preset
|
||||
try {
|
||||
val anonymizer = VoiceAnonymizer()
|
||||
val result = anonymizer.anonymize(originalFile, preset)
|
||||
@@ -1035,7 +1035,7 @@ open class ShortNotePostViewModel :
|
||||
)
|
||||
}
|
||||
} finally {
|
||||
isProcessingPreset = false
|
||||
processingPreset = null
|
||||
processingJob = null
|
||||
}
|
||||
}
|
||||
@@ -1051,7 +1051,7 @@ open class ShortNotePostViewModel :
|
||||
isUploadingVoice = false
|
||||
voiceOrchestrator = null
|
||||
selectedPreset = VoicePreset.NONE
|
||||
isProcessingPreset = false
|
||||
processingPreset = null
|
||||
}
|
||||
|
||||
private fun deleteVoiceLocalFile() {
|
||||
|
||||
+1
-1
@@ -198,7 +198,7 @@ private fun VoiceReplyScreenBody(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
VoicePresetSelector(
|
||||
selectedPreset = viewModel.selectedPreset,
|
||||
isProcessing = viewModel.isProcessingPreset,
|
||||
processingPreset = viewModel.processingPreset,
|
||||
onPresetSelected = { viewModel.selectPreset(it) },
|
||||
)
|
||||
}
|
||||
|
||||
+7
-6
@@ -71,7 +71,7 @@ class VoiceReplyViewModel : ViewModel() {
|
||||
var isUploading: Boolean by mutableStateOf(false)
|
||||
|
||||
var selectedPreset: VoicePreset by mutableStateOf(VoicePreset.NONE)
|
||||
var isProcessingPreset: Boolean by mutableStateOf(false)
|
||||
var processingPreset: VoicePreset? by mutableStateOf(null)
|
||||
var distortedFiles: Map<VoicePreset, AnonymizedResult> by mutableStateOf(emptyMap())
|
||||
private var processingJob: Job? = null
|
||||
|
||||
@@ -138,6 +138,7 @@ class VoiceReplyViewModel : ViewModel() {
|
||||
fun selectRecording(recording: RecordingResult) {
|
||||
cancelUpload()
|
||||
processingJob?.cancel()
|
||||
processingPreset = null
|
||||
deleteVoiceLocalFile()
|
||||
voiceRecording = recording
|
||||
voiceLocalFile = recording.file
|
||||
@@ -175,10 +176,10 @@ class VoiceReplyViewModel : ViewModel() {
|
||||
distortedFiles = emptyMap()
|
||||
}
|
||||
|
||||
fun canSend(): Boolean = voiceRecording != null && !isUploading && !isProcessingPreset
|
||||
fun canSend(): Boolean = voiceRecording != null && !isUploading && processingPreset == null
|
||||
|
||||
fun selectPreset(preset: VoicePreset) {
|
||||
if (isProcessingPreset || preset == selectedPreset) return
|
||||
if (processingPreset != null || preset == selectedPreset) return
|
||||
|
||||
if (preset == VoicePreset.NONE) {
|
||||
selectedPreset = preset
|
||||
@@ -195,7 +196,7 @@ class VoiceReplyViewModel : ViewModel() {
|
||||
processingJob?.cancel()
|
||||
processingJob =
|
||||
viewModelScope.launch {
|
||||
isProcessingPreset = true
|
||||
processingPreset = preset
|
||||
try {
|
||||
val anonymizer = VoiceAnonymizer()
|
||||
val result = anonymizer.anonymize(originalFile, preset)
|
||||
@@ -212,7 +213,7 @@ class VoiceReplyViewModel : ViewModel() {
|
||||
)
|
||||
}
|
||||
} finally {
|
||||
isProcessingPreset = false
|
||||
processingPreset = null
|
||||
processingJob = null
|
||||
}
|
||||
}
|
||||
@@ -356,7 +357,7 @@ class VoiceReplyViewModel : ViewModel() {
|
||||
isUploading = false
|
||||
voiceOrchestrator = null
|
||||
selectedPreset = VoicePreset.NONE
|
||||
isProcessingPreset = false
|
||||
processingPreset = null
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
|
||||
Reference in New Issue
Block a user