mirror of
https://github.com/mue/mue.git
synced 2026-06-05 23:45:53 +02:00
fix(search): replace createRef with useRef for microphone icon
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
/* global chrome */
|
||||
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 { Tooltip } from 'components/Elements';
|
||||
|
||||
import EventBus from 'utils/eventbus';
|
||||
|
||||
import './search.scss';
|
||||
|
||||
function Search() {
|
||||
@@ -12,7 +14,7 @@ function Search() {
|
||||
localStorage.getItem('widgetStyle') === 'legacy' ? 'searchIcons old' : 'searchIcons',
|
||||
);
|
||||
|
||||
const micIcon = createRef();
|
||||
const micIcon = useRef(null);
|
||||
|
||||
const startSpeechRecognition = useCallback(() => {
|
||||
const voiceSearch = new window.webkitSpeechRecognition();
|
||||
@@ -64,8 +66,10 @@ function Search() {
|
||||
<MdMic className="micIcon" />
|
||||
</button>,
|
||||
);
|
||||
} else {
|
||||
setMicrophone(null);
|
||||
}
|
||||
}, [micIcon, startSpeechRecognition]);
|
||||
}, [startSpeechRecognition]);
|
||||
|
||||
useEffect(() => {
|
||||
init();
|
||||
@@ -75,6 +79,12 @@ function Search() {
|
||||
element.focus();
|
||||
}
|
||||
}
|
||||
|
||||
EventBus.on('refresh', (data) => {
|
||||
if (data === 'search') {
|
||||
init();
|
||||
}
|
||||
});
|
||||
}, [init]);
|
||||
|
||||
function searchButton(e) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import { Checkbox } from 'components/Form/Settings';
|
||||
|
||||
import EventBus from 'utils/eventbus';
|
||||
|
||||
const SearchOptions = () => {
|
||||
const SEARCH_SECTION = 'modals.main.settings.sections.search';
|
||||
|
||||
const ChromePolicyWarning = () => {
|
||||
@@ -48,6 +47,8 @@ const SearchOptions = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const SearchOptions = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header
|
||||
|
||||
Reference in New Issue
Block a user