Update types: attachments may not have url property

This commit is contained in:
Fedor Indutny 2021-03-16 10:49:19 -07:00 committed by Josh Perez
parent aeab3f8d16
commit f41ffda3e0
5 changed files with 19 additions and 16 deletions

View file

@ -256,6 +256,13 @@ export const MessageAudio: React.FC<Props> = (props: Props) => {
(async () => {
try {
if (!attachment.url) {
throw new Error(
'Expected attachment url in the MessageAudio with ' +
`state: ${state}`
);
}
const { peaks: newPeaks, duration: newDuration } = await loadAudio({
audioContext,
waveformCache,
@ -374,6 +381,12 @@ export const MessageAudio: React.FC<Props> = (props: Props) => {
audio.pause();
}
if (!attachment.url) {
throw new Error(
'Expected attachment url in the MessageAudio with ' +
`state: ${state}`
);
}
audio.src = attachment.url;
}
};