Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc057bf988 | ||
|
|
51561e2f4e |
@@ -4,6 +4,7 @@ set -ex
|
|||||||
|
|
||||||
export VITE_DEFAULT_HOMESERVER=https://call.ems.host
|
export VITE_DEFAULT_HOMESERVER=https://call.ems.host
|
||||||
export VITE_SENTRY_DSN=https://b1e328d49be3402ba96101338989fb35@sentry.matrix.org/41
|
export VITE_SENTRY_DSN=https://b1e328d49be3402ba96101338989fb35@sentry.matrix.org/41
|
||||||
|
export VITE_RAGESHAKE_SUBMIT_URL=https://element.io/bugreports/submit
|
||||||
|
|
||||||
git clone https://github.com/matrix-org/matrix-js-sdk.git
|
git clone https://github.com/matrix-org/matrix-js-sdk.git
|
||||||
cd matrix-js-sdk
|
cd matrix-js-sdk
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import React, {
|
|||||||
useContext,
|
useContext,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
|
import { ErrorView } from "./FullScreenView";
|
||||||
import { initClient, defaultHomeserver } from "./matrix-utils";
|
import { initClient, defaultHomeserver } from "./matrix-utils";
|
||||||
|
|
||||||
const ClientContext = createContext();
|
const ClientContext = createContext();
|
||||||
@@ -30,7 +31,7 @@ const ClientContext = createContext();
|
|||||||
export function ClientProvider({ children }) {
|
export function ClientProvider({ children }) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [
|
const [
|
||||||
{ loading, isAuthenticated, isPasswordlessUser, client, userName },
|
{ loading, isAuthenticated, isPasswordlessUser, client, userName, error },
|
||||||
setState,
|
setState,
|
||||||
] = useState({
|
] = useState({
|
||||||
loading: true,
|
loading: true,
|
||||||
@@ -38,6 +39,7 @@ export function ClientProvider({ children }) {
|
|||||||
isPasswordlessUser: false,
|
isPasswordlessUser: false,
|
||||||
client: undefined,
|
client: undefined,
|
||||||
userName: null,
|
userName: null,
|
||||||
|
error: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -172,6 +174,35 @@ export function ClientProvider({ children }) {
|
|||||||
window.location = "/";
|
window.location = "/";
|
||||||
}, [history]);
|
}, [history]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if ("BroadcastChannel" in window) {
|
||||||
|
const loadTime = Date.now();
|
||||||
|
const broadcastChannel = new BroadcastChannel("matrix-video-chat");
|
||||||
|
|
||||||
|
function onMessage({ data }) {
|
||||||
|
if (data.load !== undefined && data.load > loadTime) {
|
||||||
|
if (client) {
|
||||||
|
client.stopClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
setState((prev) => ({
|
||||||
|
...prev,
|
||||||
|
error: new Error(
|
||||||
|
"This application has been opened in another tab."
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
broadcastChannel.addEventListener("message", onMessage);
|
||||||
|
broadcastChannel.postMessage({ load: loadTime });
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
broadcastChannel.removeEventListener("message", onMessage);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, [client]);
|
||||||
|
|
||||||
const context = useMemo(
|
const context = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
loading,
|
loading,
|
||||||
@@ -195,6 +226,10 @@ export function ClientProvider({ children }) {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return <ErrorView error={error} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ClientContext.Provider value={context}>{children}</ClientContext.Provider>
|
<ClientContext.Provider value={context}>{children}</ClientContext.Provider>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user