From 2c760038e0adbfcb56e3352c3afb151d456e5b8e Mon Sep 17 00:00:00 2001 From: David Ralph Date: Sun, 11 Sep 2022 22:01:06 +0100 Subject: [PATCH] fix: various fixes and remove unused code --- .../helpers/autocomplete/autocomplete.scss | 2 +- .../sections/background/Background.jsx | 22 +++++++------ .../widgets/background/Maximise.jsx | 5 ++- src/components/widgets/quote/Quote.jsx | 1 - src/components/widgets/search/Search.jsx | 16 +++------- src/modules/helpers/interval.js | 31 ------------------- 6 files changed, 22 insertions(+), 55 deletions(-) delete mode 100644 src/modules/helpers/interval.js diff --git a/src/components/helpers/autocomplete/autocomplete.scss b/src/components/helpers/autocomplete/autocomplete.scss index abaa51d6..fac9621e 100644 --- a/src/components/helpers/autocomplete/autocomplete.scss +++ b/src/components/helpers/autocomplete/autocomplete.scss @@ -40,5 +40,5 @@ } .micActive { - box-shadow: 0px 0px 50px 9px #e74c3c !important; + box-shadow: 0px 0px 50px 1px #e74c3c !important; } diff --git a/src/components/modals/main/settings/sections/background/Background.jsx b/src/components/modals/main/settings/sections/background/Background.jsx index 6659a4fd..25d90840 100644 --- a/src/components/modals/main/settings/sections/background/Background.jsx +++ b/src/components/modals/main/settings/sections/background/Background.jsx @@ -68,10 +68,12 @@ export default class BackgroundSettings extends PureComponent { subtitle={variables.getMessage( 'modals.mani.settings.sections.background.intervanl.subtitle', )} - final={localStorage.getItem('photo_packs') && - this.state.backgroundType !== 'custom' && - this.state.backgroundType !== 'colour' && - this.state.backgroundType !== 'api'} + final={ + localStorage.getItem('photo_packs') && + this.state.backgroundType !== 'custom' && + this.state.backgroundType !== 'colour' && + this.state.backgroundType !== 'api' + } > - + @@ -433,9 +433,11 @@ export default class BackgroundSettings extends PureComponent { {/* // todo: ideally refactor all of this file, but we need interval to appear on marketplace too */} - {(this.state.backgroundType === 'api' || - this.state.backgroundType === 'custom' || - this.state.marketplaceEnabled) ? interval : null} + {this.state.backgroundType === 'api' || + this.state.backgroundType === 'custom' || + this.state.marketplaceEnabled + ? interval + : null} {backgroundSettings} ) : null} diff --git a/src/components/widgets/background/Maximise.jsx b/src/components/widgets/background/Maximise.jsx index 06cf75a2..bf5d1558 100644 --- a/src/components/widgets/background/Maximise.jsx +++ b/src/components/widgets/background/Maximise.jsx @@ -27,7 +27,10 @@ export default class Maximise extends PureComponent { let backgroundFilter; if (filter === true) { - backgroundFilter = localStorage.getItem('backgroundFilter'); + const filterData = localStorage.getItem('backgroundFilter'); + if (filterData !== 'none') { + backgroundFilter = filterData; + } } element.setAttribute( diff --git a/src/components/widgets/quote/Quote.jsx b/src/components/widgets/quote/Quote.jsx index 3d6ce0e5..59d40f26 100644 --- a/src/components/widgets/quote/Quote.jsx +++ b/src/components/widgets/quote/Quote.jsx @@ -17,7 +17,6 @@ import ShareModal from '../../helpers/sharemodal/ShareModal'; import offline_quotes from './offline_quotes.json'; -import Interval from 'modules/helpers/interval'; import EventBus from 'modules/helpers/eventbus'; import './quote.scss'; diff --git a/src/components/widgets/search/Search.jsx b/src/components/widgets/search/Search.jsx index 8a98fe9b..80b1bdf6 100644 --- a/src/components/widgets/search/Search.jsx +++ b/src/components/widgets/search/Search.jsx @@ -1,6 +1,6 @@ import variables from 'modules/variables'; import { PureComponent, createRef } from 'react'; -import { MdSearch, MdMic, MdSettings } from 'react-icons/md'; +import { MdSearch, MdMic, MdScreenSearchDesktop } from 'react-icons/md'; import Tooltip from 'components/helpers/tooltip/Tooltip'; import AutocompleteInput from 'components/helpers/autocomplete/Autocomplete'; @@ -133,15 +133,9 @@ export default class Search extends PureComponent { } toggleDropdown() { - if (this.state.searchDropdown === 'hidden') { - this.setState({ - searchDropdown: 'visible', - }); - } else { - this.setState({ - searchDropdown: 'hidden', - }); - } + this.setState({ + searchDropdown: (this.state.searchDropdown === 'hidden') ? 'visible' : 'hidden', + }); } setSearch(name, custom) { @@ -201,7 +195,7 @@ export default class Search extends PureComponent { {localStorage.getItem('searchDropdown') === 'true' ? ( ) : ( diff --git a/src/modules/helpers/interval.js b/src/modules/helpers/interval.js deleted file mode 100644 index 47bf54bd..00000000 --- a/src/modules/helpers/interval.js +++ /dev/null @@ -1,31 +0,0 @@ -// based on https://stackoverflow.com/a/47009962 -// it has been brought to my attention (many) times that this is horribly broken if the time -// on the "Change every" setting is longer than 1 minute. I wasn't going to wait days to see -// if the function worked, so i just assumed it did. i apologise. this function will be -// replaced entirely in the future probably -export default function interval(callback, interval, name) { - const key = name + 'interval'; - const ms = localStorage.getItem(key); - const now = Date.now(); - - const executeCallback = () => { - localStorage.setItem(key, Date.now()); - callback(); - }; - - if (ms) { - const delta = now - parseInt(ms); - if (delta > interval) { - setInterval(executeCallback, interval); - } else { - setTimeout(() => { - setInterval(executeCallback, interval); - executeCallback(); - }, interval - delta); - } - } else { - setInterval(executeCallback, interval); - } - - localStorage.setItem(key, now); -}