feat(settings): prompt for audio access from button (#263)

This commit is contained in:
appare 2021-11-01 06:40:04 +09:00 committed by GitHub
parent b09ccd90ba
commit d5c8749b80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 6 deletions

View file

@ -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) =>

View file

@ -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;