From a21528f9981ccf382f2ce3465a752d765b4fd243 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Sat, 13 Apr 2024 23:47:09 +0100 Subject: [PATCH] fix: patch background fx, attempt navbar fix --- src/features/background/Background.jsx | 58 +++------------ .../background/options/BackgroundOptions.jsx | 6 +- src/features/navbar/Navbar.jsx | 9 +-- src/features/navbar/options/NavbarOptions.jsx | 73 +++++-------------- .../welcome/components/Sections/Final.jsx | 2 +- src/i18n/locales/en_GB.json | 1 + 6 files changed, 40 insertions(+), 109 deletions(-) diff --git a/src/features/background/Background.jsx b/src/features/background/Background.jsx index 943feea9..0bfc965d 100644 --- a/src/features/background/Background.jsx +++ b/src/features/background/Background.jsx @@ -418,7 +418,18 @@ export default class Background extends PureComponent { } else if (backgroundType !== this.state.type) { return refresh(); } + } + // uninstall photo pack reverts your background to what you had previously + if ( + data === 'marketplacebackgrounduninstall' || + data === 'backgroundwelcome' || + data === 'backgroundrefresh' + ) { + refresh(); + } + + if (data === 'backgroundeffect') { // background effects so we don't get another image again const backgroundFilterSetting = localStorage.getItem('backgroundFilter'); const backgroundFilter = backgroundFilterSetting && backgroundFilterSetting !== 'none'; @@ -448,15 +459,6 @@ export default class Background extends PureComponent { }`; } } - - // uninstall photo pack reverts your background to what you had previously - if ( - data === 'marketplacebackgrounduninstall' || - data === 'backgroundwelcome' || - data === 'backgroundrefresh' - ) { - refresh(); - } }); if (localStorage.getItem('welcomeTab')) { @@ -476,43 +478,6 @@ export default class Background extends PureComponent { this.getBackground(); localStorage.setItem('backgroundStartTime', Date.now()); } - - const test = localStorage.getItem('backgroundchange'); - - this.interval = setInterval(() => { - const targetTime = Number(Number(localStorage.getItem('backgroundStartTime')) + Number(test)); - const currentTime = Number(Date.now()); - const type = localStorage.getItem('backgroundType'); - - if (test !== null && test !== 'refresh') { - if (currentTime >= targetTime) { - element.classList.remove('fade-in'); - this.getBackground(); - localStorage.setItem('backgroundStartTime', Date.now()); - } else { - try { - const current = JSON.parse(localStorage.getItem('currentBackground')); - if (current.type !== type) { - this.getBackground(); - } - const offline = localStorage.getItem('offlineMode'); - if (current.url.startsWith('http') && offline === 'false') { - if (this.state.firstTime !== true) { - this.setState(current); - } - } else if (current.url.startsWith('http')) { - this.setState(getOfflineImage()); - } - if (this.state.firstTime !== true) { - this.setState(current); - } - this.setState({ firstTime: true }); - } catch (e) { - this.setBackground(); - } - } - } - }); } // only set once we've got the info @@ -526,7 +491,6 @@ export default class Background extends PureComponent { componentWillUnmount() { EventBus.off('refresh'); - clearInterval(this.interval); } render() { diff --git a/src/features/background/options/BackgroundOptions.jsx b/src/features/background/options/BackgroundOptions.jsx index e701b28c..d2958399 100644 --- a/src/features/background/options/BackgroundOptions.jsx +++ b/src/features/background/options/BackgroundOptions.jsx @@ -551,7 +551,7 @@ class BackgroundOptions extends PureComponent { default="90" display="%" marks={values.background} - category="background" + category="backgroundeffect" element="#backgroundImage" /> this.setState({ backgroundFilter: value })} - category="background" + category="backgroundeffect" element="#backgroundImage" items={[ { @@ -612,7 +612,7 @@ class BackgroundOptions extends PureComponent { default="0" display="%" marks={values.background} - category="background" + category="backgroundeffect" element="#backgroundImage" /> )} diff --git a/src/features/navbar/Navbar.jsx b/src/features/navbar/Navbar.jsx index c7c4f9c4..917087d9 100644 --- a/src/features/navbar/Navbar.jsx +++ b/src/features/navbar/Navbar.jsx @@ -3,13 +3,9 @@ import { PureComponent, createRef } from 'react'; import { MdSettings } from 'react-icons/md'; -// import Notes from './buttons/Notes'; -// import Todo from './buttons/Todo'; -// import Apps from './buttons/Apps'; - import { Notes, Todo, Apps, Refresh, Maximise } from './components'; - import { Tooltip } from 'components/Elements'; + import EventBus from 'utils/eventbus'; import './scss/index.scss'; @@ -67,6 +63,9 @@ class Navbar extends PureComponent { refreshEnabled: localStorage.getItem('refresh'), refreshOption: localStorage.getItem('refreshOption'), }); + + this.forceUpdate(); + try { this.updateRefreshText(); this.setZoom(); diff --git a/src/features/navbar/options/NavbarOptions.jsx b/src/features/navbar/options/NavbarOptions.jsx index 21bf3e28..32d455b3 100644 --- a/src/features/navbar/options/NavbarOptions.jsx +++ b/src/features/navbar/options/NavbarOptions.jsx @@ -1,6 +1,6 @@ import variables from 'config/variables'; -import { useState, memo, useEffect } from 'react'; +import { useState, memo } from 'react'; import Modal from 'react-modal'; import { @@ -144,24 +144,29 @@ function NavbarOptions() { const NavbarOptions = () => { const NavbarButton = ({ icon, messageKey, settingName }) => { const [isDisabled, setIsDisabled] = useState(localStorage.getItem(settingName) === 'false'); - - useEffect(() => { - localStorage.setItem(settingName, isDisabled ? 'false' : 'true'); - }, [isDisabled, settingName]); - const handleClick = () => { + localStorage.setItem(settingName, !isDisabled); + + if (settingName === 'refresh') { + setShowRefreshOptions(!showRefreshOptions); + } else if (settingName === 'appsEnabled') { + setAppsEnabled(!appsEnabled); + } + setIsDisabled(!isDisabled); + variables.stats.postEvent( 'setting', `${settingName} ${!isDisabled === true ? 'enabled' : 'disabled'}`, ); + EventBus.emit('refresh', 'navbar'); }; return (