diff --git a/src/components/views/audio_messages/AudioPlayer.tsx b/src/components/views/audio_messages/AudioPlayer.tsx index c444d9251d..0fad3e9f64 100644 --- a/src/components/views/audio_messages/AudioPlayer.tsx +++ b/src/components/views/audio_messages/AudioPlayer.tsx @@ -1,5 +1,5 @@ /* -Copyright 2021 - 2022 The Matrix.org Foundation C.I.C. +Copyright 2021 - 2023 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import AudioPlayerBase from "./AudioPlayerBase"; import { PlaybackState } from "../../../audio/Playback"; export default class AudioPlayer extends AudioPlayerBase { - protected renderFileSize(): string { + protected renderFileSize(): string | null { const bytes = this.props.playback.sizeBytes; if (!bytes) return null; diff --git a/src/components/views/audio_messages/Clock.tsx b/src/components/views/audio_messages/Clock.tsx index ae0239cd42..4aad634903 100644 --- a/src/components/views/audio_messages/Clock.tsx +++ b/src/components/views/audio_messages/Clock.tsx @@ -1,5 +1,5 @@ /* -Copyright 2021 The Matrix.org Foundation C.I.C. +Copyright 2021 - 2023 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -46,7 +46,8 @@ export default class Clock extends React.Component { public render(): React.ReactNode { return ( - {this.props.formatFn(this.props.seconds)} + {/* formatFn set by defaultProps */} + {this.props.formatFn!(this.props.seconds)} ); } diff --git a/src/components/views/audio_messages/DevicesContextMenu.tsx b/src/components/views/audio_messages/DevicesContextMenu.tsx index d02aba3907..cabfa14faa 100644 --- a/src/components/views/audio_messages/DevicesContextMenu.tsx +++ b/src/components/views/audio_messages/DevicesContextMenu.tsx @@ -1,5 +1,5 @@ /* -Copyright 2022 The Matrix.org Foundation C.I.C. +Copyright 2022 - 2023 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ export const DevicesContextMenu: React.FC = ({ containerRef, currentDevic {}} - {...toLeftOrRightOf(containerRef.current.getBoundingClientRect(), 0)} + {...(containerRef.current ? toLeftOrRightOf(containerRef.current.getBoundingClientRect(), 0) : {})} > {deviceOptions} diff --git a/src/components/views/audio_messages/PlaybackClock.tsx b/src/components/views/audio_messages/PlaybackClock.tsx index 5dd7dc14cf..e9f7a5c76c 100644 --- a/src/components/views/audio_messages/PlaybackClock.tsx +++ b/src/components/views/audio_messages/PlaybackClock.tsx @@ -1,5 +1,5 @@ /* -Copyright 2021 The Matrix.org Foundation C.I.C. +Copyright 2021 - 2023 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ export default class PlaybackClock extends React.PureComponent { let seconds = this.state.seconds; if (this.state.playbackPhase === PlaybackState.Stopped) { if (Number.isFinite(this.props.defaultDisplaySeconds)) { - seconds = this.props.defaultDisplaySeconds; + seconds = this.props.defaultDisplaySeconds ?? this.props.playback.durationSeconds; } else { seconds = this.state.durationSeconds; }