Add useLocationNavigation to fix navigation during browser media prompts
This commit is contained in:
@@ -7,6 +7,7 @@ import { LobbyView } from "./LobbyView";
|
|||||||
import { InCallView } from "./InCallView";
|
import { InCallView } from "./InCallView";
|
||||||
import { CallEndedView } from "./CallEndedView";
|
import { CallEndedView } from "./CallEndedView";
|
||||||
import { useSentryGroupCallHandler } from "./useSentryGroupCallHandler";
|
import { useSentryGroupCallHandler } from "./useSentryGroupCallHandler";
|
||||||
|
import { useLocationNavigation } from "../useLocationNavigation";
|
||||||
|
|
||||||
export function GroupCallView({
|
export function GroupCallView({
|
||||||
client,
|
client,
|
||||||
@@ -42,6 +43,7 @@ export function GroupCallView({
|
|||||||
toggleLocalVideoMuted,
|
toggleLocalVideoMuted,
|
||||||
toggleMicrophoneMuted,
|
toggleMicrophoneMuted,
|
||||||
toggleScreensharing,
|
toggleScreensharing,
|
||||||
|
requestingScreenshare,
|
||||||
isScreensharing,
|
isScreensharing,
|
||||||
localScreenshareFeed,
|
localScreenshareFeed,
|
||||||
screenshareFeeds,
|
screenshareFeeds,
|
||||||
@@ -54,6 +56,8 @@ export function GroupCallView({
|
|||||||
|
|
||||||
useSentryGroupCallHandler(groupCall);
|
useSentryGroupCallHandler(groupCall);
|
||||||
|
|
||||||
|
useLocationNavigation(requestingScreenshare);
|
||||||
|
|
||||||
const [left, setLeft] = useState(false);
|
const [left, setLeft] = useState(false);
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { getAvatarUrl } from "../matrix-utils";
|
|||||||
import { useProfile } from "../profile/useProfile";
|
import { useProfile } from "../profile/useProfile";
|
||||||
import useMeasure from "react-use-measure";
|
import useMeasure from "react-use-measure";
|
||||||
import { ResizeObserver } from "@juggle/resize-observer";
|
import { ResizeObserver } from "@juggle/resize-observer";
|
||||||
|
import { useLocationNavigation } from "../useLocationNavigation";
|
||||||
|
|
||||||
export function LobbyView({
|
export function LobbyView({
|
||||||
client,
|
client,
|
||||||
@@ -40,6 +41,8 @@ export function LobbyView({
|
|||||||
onInitLocalCallFeed();
|
onInitLocalCallFeed();
|
||||||
}, [onInitLocalCallFeed]);
|
}, [onInitLocalCallFeed]);
|
||||||
|
|
||||||
|
useLocationNavigation(state === GroupCallState.InitializingLocalCallFeed);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.room}>
|
<div className={styles.room}>
|
||||||
<Header>
|
<Header>
|
||||||
|
|||||||
25
src/useLocationNavigation.js
Normal file
25
src/useLocationNavigation.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { useHistory } from "react-router-dom";
|
||||||
|
|
||||||
|
export function useLocationNavigation(enabled = false) {
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let unblock;
|
||||||
|
|
||||||
|
if (enabled) {
|
||||||
|
unblock = history.block((tx) => {
|
||||||
|
const url = new URL(tx.pathname, window.location.href);
|
||||||
|
url.search = tx.search;
|
||||||
|
url.hash = tx.hash;
|
||||||
|
window.location = url.href;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (unblock) {
|
||||||
|
unblock();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [history, enabled]);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user