mirror of
https://github.com/mue/mue.git
synced 2026-07-28 11:11:08 +02:00
fix(search): replace createRef with useRef for microphone icon
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
/* global chrome */
|
/* global chrome */
|
||||||
import variables from 'config/variables';
|
import variables from 'config/variables';
|
||||||
import { memo, createRef, useEffect, useState, useCallback } from 'react';
|
import { memo, useRef, useEffect, useState, useCallback } from 'react';
|
||||||
import { MdSearch, MdMic } from 'react-icons/md';
|
import { MdSearch, MdMic } from 'react-icons/md';
|
||||||
import { Tooltip } from 'components/Elements';
|
import { Tooltip } from 'components/Elements';
|
||||||
|
|
||||||
|
import EventBus from 'utils/eventbus';
|
||||||
|
|
||||||
import './search.scss';
|
import './search.scss';
|
||||||
|
|
||||||
function Search() {
|
function Search() {
|
||||||
@@ -12,7 +14,7 @@ function Search() {
|
|||||||
localStorage.getItem('widgetStyle') === 'legacy' ? 'searchIcons old' : 'searchIcons',
|
localStorage.getItem('widgetStyle') === 'legacy' ? 'searchIcons old' : 'searchIcons',
|
||||||
);
|
);
|
||||||
|
|
||||||
const micIcon = createRef();
|
const micIcon = useRef(null);
|
||||||
|
|
||||||
const startSpeechRecognition = useCallback(() => {
|
const startSpeechRecognition = useCallback(() => {
|
||||||
const voiceSearch = new window.webkitSpeechRecognition();
|
const voiceSearch = new window.webkitSpeechRecognition();
|
||||||
@@ -64,8 +66,10 @@ function Search() {
|
|||||||
<MdMic className="micIcon" />
|
<MdMic className="micIcon" />
|
||||||
</button>,
|
</button>,
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
setMicrophone(null);
|
||||||
}
|
}
|
||||||
}, [micIcon, startSpeechRecognition]);
|
}, [startSpeechRecognition]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
init();
|
init();
|
||||||
@@ -75,6 +79,12 @@ function Search() {
|
|||||||
element.focus();
|
element.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EventBus.on('refresh', (data) => {
|
||||||
|
if (data === 'search') {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
});
|
||||||
}, [init]);
|
}, [init]);
|
||||||
|
|
||||||
function searchButton(e) {
|
function searchButton(e) {
|
||||||
|
|||||||
@@ -6,10 +6,9 @@ import { Checkbox } from 'components/Form/Settings';
|
|||||||
|
|
||||||
import EventBus from 'utils/eventbus';
|
import EventBus from 'utils/eventbus';
|
||||||
|
|
||||||
const SearchOptions = () => {
|
const SEARCH_SECTION = 'modals.main.settings.sections.search';
|
||||||
const SEARCH_SECTION = 'modals.main.settings.sections.search';
|
|
||||||
|
|
||||||
const ChromePolicyWarning = () => {
|
const ChromePolicyWarning = () => {
|
||||||
return (
|
return (
|
||||||
<div className="itemWarning" style={{ marginBottom: '20px' }}>
|
<div className="itemWarning" style={{ marginBottom: '20px' }}>
|
||||||
<MdOutlineWarning />
|
<MdOutlineWarning />
|
||||||
@@ -19,9 +18,9 @@ const SearchOptions = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const AdditionalOptions = () => {
|
const AdditionalOptions = () => {
|
||||||
return (
|
return (
|
||||||
<Row final={true}>
|
<Row final={true}>
|
||||||
<Content
|
<Content
|
||||||
@@ -46,7 +45,9 @@ const SearchOptions = () => {
|
|||||||
</Action>
|
</Action>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const SearchOptions = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user