From 517091cbda6d7ced4937e78b8e641e661c0ad2d0 Mon Sep 17 00:00:00 2001 From: alexsparkes Date: Mon, 5 Sep 2022 10:13:42 +0100 Subject: [PATCH] overview changes Co-authored-by: David Ralph --- .../modals/main/settings/sections/About.jsx | 31 ++++---------- .../main/settings/sections/Overview.jsx | 26 ++++++++++++ .../widgets/background/Background.jsx | 42 ++++++++++--------- src/components/widgets/quote/Quote.jsx | 6 ++- src/modules/constants.js | 6 +-- 5 files changed, 64 insertions(+), 47 deletions(-) diff --git a/src/components/modals/main/settings/sections/About.jsx b/src/components/modals/main/settings/sections/About.jsx index 8b8380ce..685bd2e7 100644 --- a/src/components/modals/main/settings/sections/About.jsx +++ b/src/components/modals/main/settings/sections/About.jsx @@ -2,7 +2,7 @@ import variables from 'modules/variables'; import { PureComponent } from 'react'; import { MdEmail, MdContactPage } from 'react-icons/md'; import { FaDiscord, FaTwitter } from 'react-icons/fa'; -import { SiGithubsponsors, SiLiberapay, SiKofi, SiPatreon } from 'react-icons/si'; +import { SiGithubsponsors, SiOpencollective } from 'react-icons/si'; import { BiDonateHeart } from 'react-icons/bi'; import Tooltip from 'components/helpers/tooltip/Tooltip'; @@ -221,7 +221,10 @@ export default class About extends PureComponent {

{variables.getMessage('modals.main.settings.sections.about.support_subtitle')}

- + {variables.getMessage('modals.main.settings.sections.about.support_donate')} @@ -234,31 +237,13 @@ export default class About extends PureComponent { - + - - - - - - - - - - - +
diff --git a/src/components/modals/main/settings/sections/Overview.jsx b/src/components/modals/main/settings/sections/Overview.jsx index 0d6bfc64..6e421621 100644 --- a/src/components/modals/main/settings/sections/Overview.jsx +++ b/src/components/modals/main/settings/sections/Overview.jsx @@ -38,6 +38,14 @@ export default class OrderSettings extends PureComponent { super(); this.state = { items: JSON.parse(localStorage.getItem('order')), + news: { + title: '', + date: '', + description: '', + link: '', + linkText: '' + }, + newsDone: false }; } @@ -96,12 +104,24 @@ export default class OrderSettings extends PureComponent { } }; + async getNews() { + const data = await (await fetch('https://api.muetab.com/news')).json(); + this.setState({ + news: data.news, + newsDone: true + }); + } + componentDidUpdate() { localStorage.setItem('order', JSON.stringify(this.state.items)); variables.stats.postEvent('setting', 'Widget order'); EventBus.dispatch('refresh', 'widgets'); } + componentDidMount() { + this.getNews(); + } + render() { return ( <> @@ -131,6 +151,12 @@ export default class OrderSettings extends PureComponent { })} +
+ {this.state.news.title} + {this.state.news.date} + {this.state.news.description} + {this.state.news.linkText} +
diff --git a/src/components/widgets/background/Background.jsx b/src/components/widgets/background/Background.jsx index 381032db..c6a89ce4 100644 --- a/src/components/widgets/background/Background.jsx +++ b/src/components/widgets/background/Background.jsx @@ -383,7 +383,7 @@ export default class Background extends PureComponent { return this.setState(JSON.parse(localStorage.getItem('welcomeImage'))); } - if (localStorage.getItem('backgroundchange') === 'refresh') { + if (localStorage.getItem('backgroundchange') === 'refresh' || (localStorage.getItem('quotechange')) === null) { try { document.getElementById('backgroundImage').classList.remove('fade-in'); document.getElementsByClassName('photoInformation')[0].classList.remove('fade-in'); @@ -394,6 +394,8 @@ export default class Background extends PureComponent { localStorage.setItem('backgroundStartTime', Date.now()); } + const test = localStorage.getItem('backgroundchange'); + this.interval = setInterval(() => { const targetTime = Number( Number(localStorage.getItem('backgroundStartTime')) + @@ -402,26 +404,28 @@ export default class Background extends PureComponent { const currentTime = Number(Date.now()); const type = localStorage.getItem('backgroundType'); - if (currentTime >= targetTime) { - console.log('Is this true?') - this.getBackground(); - localStorage.setItem('backgroundStartTime', Date.now()); - } else { - console.log('Or this?') - 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 (test !== null) { + if (currentTime >= targetTime) { + console.log('Is this true?'); + this.getBackground(); + localStorage.setItem('backgroundStartTime', Date.now()); + } else { + console.log('Or this?'); + 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') { + this.setState(current); + } else if (current.url.startsWith('http')) { + this.setState(offlineBackground()); + } this.setState(current); - } else if (current.url.startsWith('http')) { - this.setState(offlineBackground()); + } catch (e) { + this.setBackground(); } - this.setState(current); - } catch (e) { - this.setBackground(); } } }); diff --git a/src/components/widgets/quote/Quote.jsx b/src/components/widgets/quote/Quote.jsx index 2a98d563..03ca785b 100644 --- a/src/components/widgets/quote/Quote.jsx +++ b/src/components/widgets/quote/Quote.jsx @@ -359,13 +359,16 @@ export default class Quote extends PureComponent { } }); - if (localStorage.getItem('quotechange') === 'refresh') { + if (localStorage.getItem('quotechange') === 'refresh' || (localStorage.getItem('quotechange')) === null ) { this.setZoom(); this.getQuote(); localStorage.setItem('quoteStartTime', Date.now()); } + const test = localStorage.getItem('quotechange') + this.interval = setInterval(() => { + if (test !== null ) { const targetTime = Number( Number(localStorage.getItem('quoteStartTime')) + Number(localStorage.getItem('quotechange')), @@ -384,6 +387,7 @@ export default class Quote extends PureComponent { this.getQuote(); } } + } }); } diff --git a/src/modules/constants.js b/src/modules/constants.js index 933d5289..1770a73b 100644 --- a/src/modules/constants.js +++ b/src/modules/constants.js @@ -31,10 +31,8 @@ export const DISCORD_SERVER = 'zv8C9F8'; export const COPYRIGHT_NAME = 'The Mue Authors'; export const COPYRIGHT_YEAR = '2018'; export const COPYRIGHT_LICENSE = 'BSD-3-Clause License'; -export const LIBERAPAY_USERNAME = 'mue'; -export const SPONSORS_USERNAME = 'davidcralph'; -export const KOFI_USERNAME = 'davidcralph'; -export const PATREON_USERNAME = 'davidcralph'; +export const OPENCOLLECTIVE_USERNAME = 'mue'; +export const SPONSORS_USERNAME = 'mue'; export const OFFLINE_IMAGES = 20;