From de24d1146395942ab17799ef9c7a6275a8e60feb Mon Sep 17 00:00:00 2001 From: David Ralph Date: Sun, 31 Dec 2023 22:20:35 +0000 Subject: [PATCH] fix: #514, alex's button and partially #515 --- .../modals/main/settings/Header.jsx | 56 +++++++++++-------- .../main/settings/sections/QuickLinks.jsx | 2 +- .../settings/sections/quicklinks/AddModal.jsx | 8 ++- src/translations/en_GB.json | 1 + 4 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/components/modals/main/settings/Header.jsx b/src/components/modals/main/settings/Header.jsx index 1d8a618d..aaa8660e 100644 --- a/src/components/modals/main/settings/Header.jsx +++ b/src/components/modals/main/settings/Header.jsx @@ -12,11 +12,43 @@ import { import Slider from './Slider'; import Switch from './Switch'; import SettingsItem from './SettingsItem'; +import EventBus from 'modules/helpers/eventbus'; import { values } from 'modules/helpers/settings/modals'; import Tooltip from 'components/helpers/tooltip/Tooltip'; class Header extends PureComponent { + constructor(props) { + super(props); + this.state = { + [this.props.setting]: localStorage.getItem(this.props.setting) === 'true', + }; + } + + changeSetting() { + if (localStorage.getItem(this.props.setting) === 'true') { + localStorage.setItem(this.props.setting, false); + this.setState({ [this.props.setting]: false }); + } else { + localStorage.setItem(this.props.setting, true); + this.setState({ [this.props.setting]: true }); + } + + variables.stats.postEvent( + 'setting', + `${this.props.name} ${this.state.checked === true ? 'enabled' : 'disabled'}`, + ); + + if (this.props.element) { + if (!document.querySelector(this.props.element)) { + document.querySelector('.reminder-info').style.display = 'flex'; + return localStorage.setItem('showReminder', true); + } + } + + EventBus.emit('refresh', this.props.category); + } + render() { return ( <> @@ -35,15 +67,9 @@ class Header extends PureComponent { {this.props.switch && (