mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-05 19:59:20 +00:00
Merge branch 'main' into dbkr/postmessage_ptt_jan2023
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
Full mesh group calls powered by [Matrix](https://matrix.org), implementing [MatrixRTC](https://github.com/matrix-org/matrix-spec-proposals/blob/matthew/group-voip/proposals/3401-group-voip.md).
|
Full mesh group calls powered by [Matrix](https://matrix.org), implementing [MatrixRTC](https://github.com/matrix-org/matrix-spec-proposals/blob/matthew/group-voip/proposals/3401-group-voip.md).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
To try it out, visit our hosted version at [call.element.io](https://call.element.io). You can also find the latest development version continuously deployed to [element-call.netlify.app](https://element-call.netlify.app).
|
To try it out, visit our hosted version at [call.element.io](https://call.element.io). You can also find the latest development version continuously deployed to [element-call.netlify.app](https://element-call.netlify.app).
|
||||||
|
|
||||||
## Host it yourself
|
## Host it yourself
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
import React, { useCallback, useState, useRef } from "react";
|
import React, { useCallback, useState, useRef } from "react";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { useSpring, animated } from "@react-spring/web";
|
import { useSpring, animated } from "@react-spring/web";
|
||||||
|
import { logger } from "@sentry/utils";
|
||||||
|
|
||||||
import styles from "./PTTButton.module.css";
|
import styles from "./PTTButton.module.css";
|
||||||
import { ReactComponent as MicIcon } from "../icons/Mic.svg";
|
import { ReactComponent as MicIcon } from "../icons/Mic.svg";
|
||||||
@@ -68,11 +69,23 @@ export const PTTButton: React.FC<Props> = ({
|
|||||||
enqueueNetworkWaiting(true, 100);
|
enqueueNetworkWaiting(true, 100);
|
||||||
startTalking();
|
startTalking();
|
||||||
}, [enqueueNetworkWaiting, startTalking, buttonHeld]);
|
}, [enqueueNetworkWaiting, startTalking, buttonHeld]);
|
||||||
|
|
||||||
const unhold = useCallback(() => {
|
const unhold = useCallback(() => {
|
||||||
|
if (!buttonHeld) return;
|
||||||
setButtonHeld(false);
|
setButtonHeld(false);
|
||||||
setNetworkWaiting(false);
|
setNetworkWaiting(false);
|
||||||
stopTalking();
|
stopTalking();
|
||||||
}, [setNetworkWaiting, stopTalking]);
|
}, [setNetworkWaiting, stopTalking, buttonHeld]);
|
||||||
|
|
||||||
|
const onMouseUp = useCallback(() => {
|
||||||
|
logger.info("Mouse up event: unholding PTT button");
|
||||||
|
unhold();
|
||||||
|
}, [unhold]);
|
||||||
|
|
||||||
|
const onBlur = useCallback(() => {
|
||||||
|
logger.info("Blur event: unholding PTT button");
|
||||||
|
unhold();
|
||||||
|
}, [unhold]);
|
||||||
|
|
||||||
const onButtonMouseDown = useCallback(
|
const onButtonMouseDown = useCallback(
|
||||||
(e: React.MouseEvent<HTMLButtonElement>) => {
|
(e: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
@@ -85,7 +98,7 @@ export const PTTButton: React.FC<Props> = ({
|
|||||||
// These listeners go on the window so even if the user's cursor / finger
|
// These listeners go on the window so even if the user's cursor / finger
|
||||||
// leaves the button while holding it, the button stays pushed until
|
// leaves the button while holding it, the button stays pushed until
|
||||||
// they stop clicking / tapping.
|
// they stop clicking / tapping.
|
||||||
useEventTarget(window, "mouseup", unhold);
|
useEventTarget(window, "mouseup", onMouseUp);
|
||||||
useEventTarget(
|
useEventTarget(
|
||||||
window,
|
window,
|
||||||
"touchend",
|
"touchend",
|
||||||
@@ -103,6 +116,8 @@ export const PTTButton: React.FC<Props> = ({
|
|||||||
}
|
}
|
||||||
if (!touchFound) return;
|
if (!touchFound) return;
|
||||||
|
|
||||||
|
logger.info("Touch event ended: unholding PTT button");
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
unhold();
|
unhold();
|
||||||
setActiveTouchId(null);
|
setActiveTouchId(null);
|
||||||
@@ -163,6 +178,8 @@ export const PTTButton: React.FC<Props> = ({
|
|||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
logger.info("Keyup event for spacebar: unholding PTT button");
|
||||||
|
|
||||||
unhold();
|
unhold();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -171,7 +188,7 @@ export const PTTButton: React.FC<Props> = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
// TODO: We will need to disable this for a global PTT hotkey to work
|
// TODO: We will need to disable this for a global PTT hotkey to work
|
||||||
useEventTarget(window, "blur", unhold);
|
useEventTarget(window, "blur", onBlur);
|
||||||
|
|
||||||
const prefersReducedMotion = usePrefersReducedMotion();
|
const prefersReducedMotion = usePrefersReducedMotion();
|
||||||
const { shadow } = useSpring({
|
const { shadow } = useSpring({
|
||||||
|
|||||||
Reference in New Issue
Block a user