Skip to content
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

Handle 'voiceRecording' attachment type as audio #2036

Closed
2 tasks
tomvalorsa opened this issue Jun 27, 2023 · 3 comments
Closed
2 tasks

Handle 'voiceRecording' attachment type as audio #2036

tomvalorsa opened this issue Jun 27, 2023 · 3 comments
Labels
feature New capability

Comments

@tomvalorsa
Copy link

Motivation
Handle 'voiceRecording' attachments in the same way as existing 'audio' attachments.

We have a web app and an iOS app. The iOS SDK added functionality to allow users to record and play voice notes. stream-chat-react does not currently have this functionality as far as I'm aware, and when I recently contacted support it seems that it's not a high priority task.

Proposed solution
Given that full voice note support might not be a priority in the short/medium-term, it would be useful for users to at least be able to listen to voice notes they have received. Using the audio attachment UI for voice notes could be a nice compromise. A quick look in the code suggests that adjusting isAudioAttachment to also consider attachments of type 'voiceRecording' as audio attachments could solve this problem (caveat: I don't have a great deal of familiarity with the codebase and am likely missing context/complexity around this feature, so this is more of an idea to get the ball rolling).

Acceptance Criteria

  • Voice recordings are playable audio attachments, rather than downloadable files.
  • Any related tests are updated/extended.
@tomvalorsa tomvalorsa added the feature New capability label Jun 27, 2023
@tomvalorsa
Copy link
Author

tomvalorsa commented Jun 27, 2023

For clarity (and for anyone else reading this who needs something similar) I just got a basic/hacky version of this working using a specialised version of the Attachment component which I then passed to Channel as a prop. This is basically what I'm referring to above:

import {
  Attachment,
  AttachmentProps,
  Audio,
  FileAttachment,
  FileAttachmentProps,
} from 'stream-chat-react'

const CustomFile = (props: FileAttachmentProps): JSX.Element => {
  if (props.attachment.type === 'voiceRecording') {
    return <Audio og={props.attachment} />
  }

  return <FileAttachment {...props} />
}

const SpecialisedAttachment = (props: AttachmentProps): JSX.Element => (
  <Attachment File={CustomFile} {...props} />
)

@arnautov-anton
Copy link
Contributor

Hey, @tomvalorsa! Thank you for submitting this feature request - we actually have this one in the pipeline (see draft PR) but as our support engineers mentioned this currently isn't being prioritised and thus the development was paused - so as this is already being developed we won't be producing any other simplified versions. In the meantime the best approach would be to use custom solution like the one you posted. Thank you for your understanding. Follow the aforementioned PR for further updates.

@MartinCupela
Copy link
Contributor

The feature has been added with [email protected].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New capability
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants