-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AND-401] Fix audio recordings not paused #5685
base: develop
Are you sure you want to change the base?
Conversation
SDK Size Comparison 📏
|
val audioPlayer = ChatClient.instance().audioPlayer | ||
audioPlayer.pause() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our UI should't use the ChatClient itself.
Could we move this logic to the ViewModel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to re-wire it to go through the VM.
private val pauseAudioPlayerListener = object : DefaultLifecycleObserver { | ||
override fun onPause(owner: LifecycleOwner) { | ||
ChatClient.instance().audioPlayer.pause() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same case here, ChatClient
shouldn't be used within our UI
|
🎯 Goal
A playing audio recording attachment in the Message List is not paused/stopped in the following scenarios:
🛠 Implementation details
ui-common
audioHash
is created for both XML and Compose SDKs. On the XML SDK, theaudioHash
was generated asAttachment::hashCode
, while on the Compose SDK theaudioHash
was generated as(attachment.assetUrl ?: attachment.upload?.toUri()?.toString()).hashCode()
. This is now unified in theAttachment::audioHash
extension, and the same is used in both SDK. This is needed for the change inMessageListController
:chatClient.deleteMessage()
, in theMessageListController
, we check if the deleted message has a playing audio recording -> by comparing thechatClient.audioPlayer.currentPlayingId
with themessage.attachment.audioHash
. If the message currently being deleted has a playing audio, pause it before launching delete request.ui-components
LifecycleObserver
in the audio recording attachment view holder, which will pause any running audio inonPause
.MessageListView
, to handle the case when the audio recording viewHolder is recycled (when scrolling away) which causes the item-level observer to be removed.MessageListView
observer is enough to fix the bug, but I added the one on the Item for the case when a customer would use theMediaAttachmentsViewHolder
independently form theMessageListView
compose
LifecycleEventEffect
inAudioRecordAttachmentContent
andAudioRecordAttachmentPreviewContent
, which pause any running audio inonPause
.MessageList
, to handle the case when the audio recording item composable is disposed (when scrolling away) which causes the item-level effect to be removed.MessageListView
observer is enough to fix the bug, but I added the one on the Item for the case when a customer would use theAudioRecordAttachmentContent
independently form theMessageList
🎨 UI Changes
compose-before.mp4
compose-after.mp4
xml-before.mp4
xml-after.mp4
🧪 Testing