mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-26 00:50:56 -05:00
feat(settings): prompt for audio access from button (#263)
This commit is contained in:
parent
b09ccd90ba
commit
d5c8749b80
2 changed files with 34 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import styles from "./Panes.module.scss";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import { useEffect, useState } from "preact/hooks";
|
import { useEffect, useState } from "preact/hooks";
|
||||||
|
|
||||||
|
@ -7,6 +8,7 @@ import { voiceState } from "../../../lib/vortex/VoiceState";
|
||||||
|
|
||||||
import { connectState } from "../../../redux/connector";
|
import { connectState } from "../../../redux/connector";
|
||||||
|
|
||||||
|
import Button from "../../../components/ui/Button";
|
||||||
import ComboBox from "../../../components/ui/ComboBox";
|
import ComboBox from "../../../components/ui/ComboBox";
|
||||||
import Overline from "../../../components/ui/Overline";
|
import Overline from "../../../components/ui/Overline";
|
||||||
import Tip from "../../../components/ui/Tip";
|
import Tip from "../../../components/ui/Tip";
|
||||||
|
@ -51,10 +53,6 @@ export function Component() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
askOrGetPermission();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mediaStream) {
|
if (!mediaStream) {
|
||||||
return;
|
return;
|
||||||
|
@ -71,7 +69,7 @@ export function Component() {
|
||||||
}, [mediaStream]);
|
}, [mediaStream]);
|
||||||
|
|
||||||
const handleAskForPermission = (
|
const handleAskForPermission = (
|
||||||
ev: JSX.TargetedMouseEvent<HTMLAnchorElement>,
|
ev: JSX.TargetedMouseEvent<HTMLElement>,
|
||||||
) => {
|
) => {
|
||||||
stopPropagation(ev);
|
stopPropagation(ev);
|
||||||
setError(undefined);
|
setError(undefined);
|
||||||
|
@ -80,10 +78,25 @@ export function Component() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div class={styles.audio}>
|
||||||
<h3>
|
<h3>
|
||||||
<Text id="app.settings.pages.audio.input_device" />
|
<Text id="app.settings.pages.audio.input_device" />
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
|
{!permission && (
|
||||||
|
<div className={styles.grant_permission}>
|
||||||
|
<span className={styles.description}>
|
||||||
|
<Text id="app.settings.pages.audio.tip_grant_permission" />
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
compact
|
||||||
|
onClick={(e) => handleAskForPermission(e)}
|
||||||
|
error>
|
||||||
|
<Text id="app.settings.pages.audio.button_grant" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<ComboBox
|
<ComboBox
|
||||||
value={window.localStorage.getItem("audioInputDevice") ?? 0}
|
value={window.localStorage.getItem("audioInputDevice") ?? 0}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
|
|
|
@ -134,6 +134,21 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.audio {
|
||||||
|
.grant_permission {
|
||||||
|
margin-bottom: 18px;
|
||||||
|
.description {
|
||||||
|
font-weight: 400;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
overflow: hidden;
|
||||||
|
font-size: 12px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.appearance {
|
.appearance {
|
||||||
.theme {
|
.theme {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
|
Loading…
Reference in a new issue