Skip to content

Commit

Permalink
Fallback to upload file on case the asset url is null
Browse files Browse the repository at this point in the history
  • Loading branch information
JcMinarro committed Nov 29, 2024
1 parent a6e8381 commit dc72d7d
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import io.getstream.chat.android.client.extensions.durationInMs
Expand Down Expand Up @@ -140,7 +141,10 @@ public fun AudioRecordAttachmentContent(
val viewModel = viewModel(AudioPlayerViewModel::class.java, factory = viewModelFactory)

val audioRecordings = attachmentState.message.attachments
.filter { attachment -> attachment.isAudioRecording() && attachment.assetUrl != null }
.filter { attachment ->
val attachmentUrl = attachment.assetUrl ?: attachment.upload?.toUri()?.toString()
attachment.isAudioRecording() && attachmentUrl != null
}

val playerState by viewModel.state.collectAsStateWithLifecycle()

Expand Down Expand Up @@ -241,7 +245,7 @@ internal fun AudioRecordAttachmentContentItemBase(
onThumbDragStop: (Attachment, Float) -> Unit = { _, _ -> },
tailContent: @Composable (isPlaying: Boolean) -> Unit = {},
) {
val attachmentUrl = attachment.assetUrl
val attachmentUrl = attachment.assetUrl ?: attachment.upload?.toUri()?.toString()
val isCurrentAttachment = attachmentUrl == playerState.current.audioUri
val trackProgress = playerState.current.playingProgress.takeIf { isCurrentAttachment }
?: attachmentUrl?.let { playerState.seekTo.getOrDefault(it.hashCode(), 0f) } ?: 0f
Expand Down

0 comments on commit dc72d7d

Please sign in to comment.