code review: abort posting message if voice upload fails

This commit is contained in:
davotoula
2025-12-15 19:39:24 +01:00
parent a370112bc5
commit 3dd4249220
@@ -486,10 +486,15 @@ open class ShortNotePostViewModel :
val serverToUse = voiceSelectedServer ?: accountViewModel.account.settings.defaultFileServer val serverToUse = voiceSelectedServer ?: accountViewModel.account.settings.defaultFileServer
uploadVoiceMessageSync( uploadVoiceMessageSync(
serverToUse, serverToUse,
{ _, _ -> }, // Ignore errors during sync upload before post { _, _ -> }, // Error handling is done by checking voiceMetadata below
) )
// Abort if upload failed - don't post without voice data
if (voiceMetadata == null) {
Log.w("ShortNotePostViewModel", "Voice upload failed, aborting post")
return
}
// Update default server if voice message was successfully uploaded // Update default server if voice message was successfully uploaded
if (voiceMetadata != null && voiceSelectedServer != null && voiceSelectedServer?.type != ServerType.NIP95) { if (voiceSelectedServer != null && voiceSelectedServer?.type != ServerType.NIP95) {
account.settings.changeDefaultFileServer(voiceSelectedServer!!) account.settings.changeDefaultFileServer(voiceSelectedServer!!)
} }
} }