diff --git a/src/components/modals/Update.jsx b/src/components/modals/Update.jsx index ad249295..8536a4a9 100644 --- a/src/components/modals/Update.jsx +++ b/src/components/modals/Update.jsx @@ -15,13 +15,6 @@ export default class Update extends React.PureComponent { } async getUpdate() { - if (localStorage.getItem('offlineMode') === 'true') { - return this.setState({ - title: this.props.language.offline.title, - html: this.props.language.offline.description - }); - } - const data = await (await fetch(Constants.API_URL + '/getUpdate')).json(); if (data.statusCode === 500 || data.title === null) { @@ -42,7 +35,14 @@ export default class Update extends React.PureComponent { } componentDidMount() { - this.getUpdate(); + if (localStorage.getItem('offlineMode') === 'true') { + return this.setState({ + title: this.props.language.offline.title, + html: this.props.language.offline.description + }); + } + + this.getUpdate(); } render() { diff --git a/src/components/modals/settings/sections/BackgroundSettings.jsx b/src/components/modals/settings/sections/BackgroundSettings.jsx index 0076bb22..c68294a7 100644 --- a/src/components/modals/settings/sections/BackgroundSettings.jsx +++ b/src/components/modals/settings/sections/BackgroundSettings.jsx @@ -230,7 +230,6 @@ export default class BackgroundSettings extends React.PureComponent { -
    searchText.value = event.results[0][0].transcript; + + voiceSearch.onresult = (event) => { + searchText.value = event.results[0][0].transcript; + } + voiceSearch.onend = () =>{ setTimeout(() => { window.location.href = this.state.url + `?${this.state.query}=` + searchText.value; @@ -28,9 +34,11 @@ export default class Search extends React.PureComponent { } } - render() { + + componentDidMount() { let url; let query = 'q'; + let microphone = null; const setting = localStorage.getItem('searchEngine'); const info = searchEngines.find(i => i.settingsName === setting); @@ -44,27 +52,24 @@ export default class Search extends React.PureComponent { url = localStorage.getItem('customSearchEngine'); } - const searchButton = () => { - const value = document.getElementById('searchtext').value || 'mue fast'; - window.location.href = url + `?${query}=` + value; - }; - - let microphone = null; if (localStorage.getItem('voiceSearch') === 'true') { - this.setState({ - url: url, - query: query - }); microphone = this.startSpeechRecognition()}/>; } + this.setState({ + url: url, + query: query, + microphone: microphone + }); + } + + render() { return (