Skip to content
Snippets Groups Projects
Unverified Commit b495066b authored by Ahmad Farhat's avatar Ahmad Farhat Committed by GitHub
Browse files

Add additional fail safe for action cable (#5453)

parent c9b69874
No related branches found
No related tags found
No related merge requests found
...@@ -48,9 +48,10 @@ export default function JoinCard() { ...@@ -48,9 +48,10 @@ export default function JoinCard() {
const currentUser = useAuth(); const currentUser = useAuth();
const { friendlyId } = useParams(); const { friendlyId } = useParams();
const [hasStarted, setHasStarted] = useState(false); const [hasStarted, setHasStarted] = useState(false);
const [joinInterval, setJoinInterval] = useState();
const publicRoom = usePublicRoom(friendlyId); const publicRoom = usePublicRoom(friendlyId);
const roomStatusAPI = useRoomStatus(friendlyId); const roomStatusAPI = useRoomStatus(friendlyId, joinInterval);
const { data: env } = useEnv(); const { data: env } = useEnv();
...@@ -76,6 +77,8 @@ export default function JoinCard() { ...@@ -76,6 +77,8 @@ export default function JoinCard() {
} }
roomStatusAPI.mutate(data); roomStatusAPI.mutate(data);
const interval = setInterval(() => roomStatusAPI.mutate(data), 5000);
setJoinInterval(interval);
}; };
const reset = () => { setHasStarted(false); };// Reset pipeline; const reset = () => { setHasStarted(false); };// Reset pipeline;
......
...@@ -19,7 +19,7 @@ import { useMutation } from 'react-query'; ...@@ -19,7 +19,7 @@ import { useMutation } from 'react-query';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import axios from '../../../helpers/Axios'; import axios from '../../../helpers/Axios';
export default function useRoomStatus(friendlyId) { export default function useRoomStatus(friendlyId, joinInterval) {
const { t } = useTranslation(); const { t } = useTranslation();
return useMutation( return useMutation(
...@@ -27,11 +27,13 @@ export default function useRoomStatus(friendlyId) { ...@@ -27,11 +27,13 @@ export default function useRoomStatus(friendlyId) {
{ {
onSuccess: ({ joinUrl }) => { onSuccess: ({ joinUrl }) => {
if (joinUrl) { if (joinUrl) {
clearInterval(joinInterval);
toast.loading(t('toast.success.room.joining_meeting')); toast.loading(t('toast.success.room.joining_meeting'));
window.location.replace(joinUrl); window.location.replace(joinUrl);
} }
}, },
onError: () => { onError: () => {
clearInterval(joinInterval);
toast.error(t('toast.error.problem_completing_action')); toast.error(t('toast.error.problem_completing_action'));
}, },
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment