Code review:

- Removed DisposableEffect cleanup
- Added cancelUpload() to selectRecording()
This commit is contained in:
davotoula
2025-12-23 11:31:32 +00:00
parent 9b2ef76250
commit 64fe4dfac6
2 changed files with 2 additions and 19 deletions
@@ -41,7 +41,6 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Alignment
@@ -85,12 +84,6 @@ fun VoiceReplyScreen(
nav.popBack()
}
DisposableEffect(Unit) {
onDispose {
viewModel.cancel()
}
}
Scaffold(
topBar = {
PostingTopBar(
@@ -107,23 +107,13 @@ class VoiceReplyViewModel : ViewModel() {
}
fun selectRecording(recording: RecordingResult) {
cancelUpload()
deleteVoiceLocalFile()
voiceRecording = recording
voiceLocalFile = recording.file
voiceMetadata = null
}
fun removeVoiceMessage() {
cancelUpload()
deleteVoiceLocalFile()
voiceRecording = null
voiceLocalFile = null
voiceMetadata = null
voiceSelectedServer = null
isUploading = false
voiceOrchestrator = null
}
private fun cancelUpload() {
uploadJob?.cancel()
uploadJob = null
@@ -175,7 +165,7 @@ class VoiceReplyViewModel : ViewModel() {
handleUploadResult(note, recording, serverToUse, result, onSuccess)
} catch (e: CancellationException) {
// User canceled, or ViewModel cleared.
Log.w("VoiceReplyViewModel", "User canceled, or ViewModel cleared", e)
} catch (e: Exception) {
val appContext = Amethyst.instance.appContext
val uploadErrorTitle = stringRes(appContext, R.string.upload_error_title)