mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-08 20:09:19 +00:00
Allow timer to be configurable.
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
"next": "Next",
|
"next": "Next",
|
||||||
"options": "Options",
|
"options": "Options",
|
||||||
"password": "Password",
|
"password": "Password",
|
||||||
|
"preferences": "Preferences",
|
||||||
"profile": "Profile",
|
"profile": "Profile",
|
||||||
"raise_hand": "Raise hand",
|
"raise_hand": "Raise hand",
|
||||||
"settings": "Settings",
|
"settings": "Settings",
|
||||||
@@ -145,6 +146,10 @@
|
|||||||
"feedback_tab_title": "Feedback",
|
"feedback_tab_title": "Feedback",
|
||||||
"more_tab_title": "More",
|
"more_tab_title": "More",
|
||||||
"opt_in_description": "<0></0><1></1>You may withdraw consent by unchecking this box. If you are currently in a call, this setting will take effect at the end of the call.",
|
"opt_in_description": "<0></0><1></1>You may withdraw consent by unchecking this box. If you are currently in a call, this setting will take effect at the end of the call.",
|
||||||
|
"preferences_tab_body": "Here you can configure extra options for an improved experience",
|
||||||
|
"preferences_tab_h4": "Preferences",
|
||||||
|
"preferences_tab_show_hand_raised_timer_description": "Show a timer when a participant raises their hand",
|
||||||
|
"preferences_tab_show_hand_raised_timer_label": "Show hand raise duration",
|
||||||
"speaker_device_selection_label": "Speaker"
|
"speaker_device_selection_label": "Speaker"
|
||||||
},
|
},
|
||||||
"star_rating_input_label_one": "{{count}} stars",
|
"star_rating_input_label_one": "{{count}} stars",
|
||||||
|
|||||||
@@ -22,21 +22,21 @@ describe("RaisedHandIndicator", () => {
|
|||||||
test("renders an indicator when a hand has been raised", () => {
|
test("renders an indicator when a hand has been raised", () => {
|
||||||
const dateTime = new Date();
|
const dateTime = new Date();
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<RaisedHandIndicator raisedHandTime={dateTime} />,
|
<RaisedHandIndicator raisedHandTime={dateTime} showTimer />,
|
||||||
);
|
);
|
||||||
expect(container.firstChild).toMatchSnapshot();
|
expect(container.firstChild).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
test("renders an indicator when a hand has been raised with the expected time", () => {
|
test("renders an indicator when a hand has been raised with the expected time", () => {
|
||||||
const dateTime = new Date(new Date().getTime() - 60000);
|
const dateTime = new Date(new Date().getTime() - 60000);
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<RaisedHandIndicator raisedHandTime={dateTime} />,
|
<RaisedHandIndicator raisedHandTime={dateTime} showTimer />,
|
||||||
);
|
);
|
||||||
expect(container.firstChild).toMatchSnapshot();
|
expect(container.firstChild).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
test("renders a smaller indicator when minature is specified", () => {
|
test("renders a smaller indicator when minature is specified", () => {
|
||||||
const dateTime = new Date();
|
const dateTime = new Date();
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<RaisedHandIndicator raisedHandTime={dateTime} minature />,
|
<RaisedHandIndicator raisedHandTime={dateTime} minature showTimer />,
|
||||||
);
|
);
|
||||||
expect(container.firstChild).toMatchSnapshot();
|
expect(container.firstChild).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,14 +13,16 @@ import styles from "./RaisedHandIndicator.module.css";
|
|||||||
export function RaisedHandIndicator({
|
export function RaisedHandIndicator({
|
||||||
raisedHandTime,
|
raisedHandTime,
|
||||||
minature,
|
minature,
|
||||||
|
showTimer,
|
||||||
}: {
|
}: {
|
||||||
raisedHandTime?: Date;
|
raisedHandTime?: Date;
|
||||||
minature?: boolean;
|
minature?: boolean;
|
||||||
|
showTimer?: boolean;
|
||||||
}): ReactNode {
|
}): ReactNode {
|
||||||
const [raisedHandDuration, setRaisedHandDuration] = useState("");
|
const [raisedHandDuration, setRaisedHandDuration] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!raisedHandTime) {
|
if (!raisedHandTime || !showTimer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const calculateTime = (): void => {
|
const calculateTime = (): void => {
|
||||||
@@ -36,7 +38,7 @@ export function RaisedHandIndicator({
|
|||||||
calculateTime();
|
calculateTime();
|
||||||
const to = setInterval(calculateTime, 1000);
|
const to = setInterval(calculateTime, 1000);
|
||||||
return (): void => clearInterval(to);
|
return (): void => clearInterval(to);
|
||||||
}, [setRaisedHandDuration, raisedHandTime]);
|
}, [setRaisedHandDuration, raisedHandTime, showTimer]);
|
||||||
|
|
||||||
if (raisedHandTime) {
|
if (raisedHandTime) {
|
||||||
return (
|
return (
|
||||||
@@ -54,7 +56,7 @@ export function RaisedHandIndicator({
|
|||||||
✋
|
✋
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<p>{raisedHandDuration}</p>
|
{showTimer && <p>{raisedHandDuration}</p>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,4 +85,9 @@ export const videoInput = new Setting<string | undefined>(
|
|||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const showHandRaisedTimer = new Setting<boolean>(
|
||||||
|
"hand-raised-show-timer",
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
export const alwaysShowSelf = new Setting<boolean>("always-show-self", true);
|
export const alwaysShowSelf = new Setting<boolean>("always-show-self", true);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { ErrorIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
|||||||
import styles from "./MediaView.module.css";
|
import styles from "./MediaView.module.css";
|
||||||
import { Avatar } from "../Avatar";
|
import { Avatar } from "../Avatar";
|
||||||
import { RaisedHandIndicator } from "../reactions/RaisedHandIndicator";
|
import { RaisedHandIndicator } from "../reactions/RaisedHandIndicator";
|
||||||
|
import { showHandRaisedTimer, useSetting } from "../settings/settings";
|
||||||
|
|
||||||
interface Props extends ComponentProps<typeof animated.div> {
|
interface Props extends ComponentProps<typeof animated.div> {
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -58,6 +59,7 @@ export const MediaView = forwardRef<HTMLDivElement, Props>(
|
|||||||
ref,
|
ref,
|
||||||
) => {
|
) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [handRaiseTimerVisible] = useSetting(showHandRaisedTimer);
|
||||||
|
|
||||||
const avatarSize = Math.round(Math.min(targetWidth, targetHeight) / 2);
|
const avatarSize = Math.round(Math.min(targetWidth, targetHeight) / 2);
|
||||||
|
|
||||||
@@ -95,6 +97,7 @@ export const MediaView = forwardRef<HTMLDivElement, Props>(
|
|||||||
<RaisedHandIndicator
|
<RaisedHandIndicator
|
||||||
raisedHandTime={raisedHandTime}
|
raisedHandTime={raisedHandTime}
|
||||||
minature={avatarSize < 96}
|
minature={avatarSize < 96}
|
||||||
|
showTimer={handRaiseTimerVisible}
|
||||||
/>
|
/>
|
||||||
<div className={styles.nameTag}>
|
<div className={styles.nameTag}>
|
||||||
{nameTagLeadingIcon}
|
{nameTagLeadingIcon}
|
||||||
|
|||||||
Reference in New Issue
Block a user