Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 7f01e31

Browse files
committed
Fix timing of voice message recording UI appearing
Fixes element-hq/element-web#18223 We delay the composer's state until a recording is truly ready here, preventing buttons from disappearing while we're still figuring things out.
1 parent 405fe43 commit 7f01e31

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/components/views/rooms/MessageComposer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,20 @@ export default class MessageComposer extends React.Component<IProps, IState> {
342342

343343
private onVoiceStoreUpdate = () => {
344344
const recording = VoiceRecordingStore.instance.activeRecording;
345-
this.setState({ haveRecording: !!recording });
346345
if (recording) {
346+
// Delay saying we have a recording until it is started, as we might not yet have A/V permissions
347+
recording.on(RecordingState.Started, () => {
348+
this.setState({ haveRecording: !!VoiceRecordingStore.instance.activeRecording });
349+
});
347350
// We show a little heads up that the recording is about to automatically end soon. The 3s
348351
// display time is completely arbitrary. Note that we don't need to deregister the listener
349352
// because the recording instance will clean that up for us.
350353
recording.on(RecordingState.EndingSoon, ({ secondsLeft }) => {
351354
this.setState({ recordingTimeLeftSeconds: secondsLeft });
352355
setTimeout(() => this.setState({ recordingTimeLeftSeconds: null }), 3000);
353356
});
357+
} else {
358+
this.setState({ haveRecording: false });
354359
}
355360
};
356361

0 commit comments

Comments
 (0)