-
Notifications
You must be signed in to change notification settings - Fork 44
[SDK-366] Parse media #818
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
Changes from 1 commit
44ffd76
d5c4c04
7374226
82f9b15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import type { IterableEmbeddedMessage } from '../../types/IterableEmbeddedMessage'; | ||
| import { IterableEmbeddedViewType } from '../../enums'; | ||
|
|
||
| /** | ||
| * This function is used to get the media to render for a given embedded view | ||
| * type and message. | ||
| * | ||
| * @param viewType - The type of view to render. | ||
| * @param message - The message to render. | ||
| * @returns The media to render. | ||
| * | ||
| * @example | ||
| * const media = getMedia(IterableEmbeddedViewType.Notification, message); | ||
| * console.log(media.url); | ||
| * console.log(media.caption); | ||
| * console.log(media.shouldShow ? 'true' : 'false'); | ||
| */ | ||
| export const getMedia = ( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this have a return type?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call -- I'll add one. |
||
| /** The type of view to render. */ | ||
| viewType: IterableEmbeddedViewType, | ||
| /** The message to render. */ | ||
| message: IterableEmbeddedMessage | ||
|
qltysh[bot] marked this conversation as resolved.
|
||
| ) => { | ||
| if (viewType === IterableEmbeddedViewType.Notification) { | ||
| return { url: null, caption: null, shouldShow: false }; | ||
| } | ||
| const url = message.elements?.mediaUrl ?? null; | ||
| const caption = message.elements?.mediaUrlCaption ?? null; | ||
| const shouldShow = !!url && url.length > 0; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DO we need the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair point. Yeah -- it's a bit redundant. |
||
| return { url, caption, shouldShow }; | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.