From c3caf2cf418605c8b83e08d5cb1a9b15311c550e Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 2 Feb 2024 11:51:32 +1100 Subject: [PATCH] chore: address pr reviews --- ts/components/conversation/Image.tsx | 5 +++-- ts/components/conversation/SessionConversation.tsx | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ts/components/conversation/Image.tsx b/ts/components/conversation/Image.tsx index 2fd207747..e3b6e519b 100644 --- a/ts/components/conversation/Image.tsx +++ b/ts/components/conversation/Image.tsx @@ -2,6 +2,7 @@ import classNames from 'classnames'; import React, { useCallback } from 'react'; import styled from 'styled-components'; +import { isNumber } from 'lodash'; import { useDisableDrag } from '../../hooks/useDisableDrag'; import { useEncryptedFileFetch } from '../../hooks/useEncryptedFileFetch'; import { AttachmentType, AttachmentTypeWithPath } from '../../types/Attachment'; @@ -78,8 +79,8 @@ export const Image = (props: Props) => { // data will be url if loading is finished and '' if not const srcData = !loading ? urlToLoad : ''; - const width = typeof _width === 'number' ? `${_width}px` : _width; - const height = typeof _height === 'number' ? `${_height}px` : _height; + const width = isNumber(_width) ? `${_width}px` : _width; + const height = isNumber(_height) ? `${_height}px` : _height; return (
{ if (isAudio(contentType)) { const objectUrl = URL.createObjectURL(file); - const duration = await getAudioDuration({ objectUrl, contentType }); - attachment.duration = duration; + + try { + const duration = await getAudioDuration({ objectUrl, contentType }); + attachment.duration = duration; + } finally { + URL.revokeObjectURL(objectUrl); + } } this.addAttachments([attachment]);