Skip to content

Commit

Permalink
fix(meteor): Close video recorder if permission denied (#30054)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh committed Aug 15, 2023
1 parent df64d55 commit 72a34a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-feet-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fixed the video recorder window not closing after permission is denied.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IMessage, IRoom } from '@rocket.chat/core-typings';
import { css } from '@rocket.chat/css-in-js';
import { Box, ButtonGroup, Button, Icon, PositionAnimated } from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useTranslation, useToastMessageDispatch } from '@rocket.chat/ui-contexts';
import type { AllHTMLAttributes, RefObject } from 'react';
import React, { useRef, useEffect, useState } from 'react';
Expand Down Expand Up @@ -94,24 +95,24 @@ const VideoMessageRecorder = ({ rid, tmid, chatContext, reference }: VideoMessag
stopVideoRecording(rid, tmid);
};

const handleCancel = () => {
const handleCancel = useMutableCallback(() => {
VideoRecorder.stop();
chat?.composer?.setRecordingVideo(false);
setTime(undefined);
stopVideoRecording(rid, tmid);
};
});

useEffect(() => {
if (!VideoRecorder.getSupportedMimeTypes()) {
return dispatchToastMessage({ type: 'error', message: t('Browser_does_not_support_recording_video') });
}

VideoRecorder.start(videoRef.current ?? undefined);
VideoRecorder.start(videoRef.current ?? undefined, (success) => (!success ? handleCancel() : undefined));

return () => {
VideoRecorder.stop();
};
}, [dispatchToastMessage, t]);
}, [dispatchToastMessage, handleCancel, t]);

return (
<PositionAnimated visible='visible' anchor={reference} placement='top-end'>
Expand Down

0 comments on commit 72a34a0

Please sign in to comment.