diff --git a/src/components/modals/main/settings/ResetModal.jsx b/src/components/modals/main/settings/ResetModal.jsx index 6c7c5fd9..4e85b6d3 100644 --- a/src/components/modals/main/settings/ResetModal.jsx +++ b/src/components/modals/main/settings/ResetModal.jsx @@ -11,8 +11,8 @@ export default function ResetModal(props) {

{language.question}

{language.information}

- - + +
); diff --git a/src/components/modals/main/settings/sections/Appearance.jsx b/src/components/modals/main/settings/sections/Appearance.jsx index 1b8bfc0c..f131b546 100644 --- a/src/components/modals/main/settings/sections/Appearance.jsx +++ b/src/components/modals/main/settings/sections/Appearance.jsx @@ -59,7 +59,7 @@ export default function AppearanceSettings() {

{appearance.accessibility.title}

{(engineName === 'Blink') ? - + : null} diff --git a/src/components/modals/main/settings/sections/QuickLinks.jsx b/src/components/modals/main/settings/sections/QuickLinks.jsx index bd5331f0..5bf4fd29 100644 --- a/src/components/modals/main/settings/sections/QuickLinks.jsx +++ b/src/components/modals/main/settings/sections/QuickLinks.jsx @@ -9,9 +9,9 @@ export default function QuickLinks() { return ( <>

{language.title}

- - - + + + ); } diff --git a/src/components/modals/main/settings/sections/Weather.jsx b/src/components/modals/main/settings/sections/Weather.jsx index d02569c6..9d6348b1 100644 --- a/src/components/modals/main/settings/sections/Weather.jsx +++ b/src/components/modals/main/settings/sections/Weather.jsx @@ -38,19 +38,19 @@ export default class TimeSettings extends React.PureComponent { return ( <>

{language.title}

- +

    {language.location}

    this.setState({ location: e.target.value })}>

- +

{language.extra_info.title}

- - - - - + + + + + ); } diff --git a/src/components/widgets/Widgets.jsx b/src/components/widgets/Widgets.jsx index 41ac2e08..09dc42b2 100644 --- a/src/components/widgets/Widgets.jsx +++ b/src/components/widgets/Widgets.jsx @@ -1,4 +1,5 @@ import React from 'react'; + import EventBus from '../../modules/helpers/eventbus'; import Clock from './time/Clock'; diff --git a/src/components/widgets/quicklinks/QuickLinks.jsx b/src/components/widgets/quicklinks/QuickLinks.jsx index 13d48093..ac0e9ca0 100644 --- a/src/components/widgets/quicklinks/QuickLinks.jsx +++ b/src/components/widgets/quicklinks/QuickLinks.jsx @@ -1,5 +1,7 @@ import React from 'react'; +import EventBus from '../../../modules/helpers/eventbus'; + import Tooltip from '@material-ui/core/Tooltip'; import TextareaAutosize from '@material-ui/core/TextareaAutosize'; @@ -17,12 +19,6 @@ export default class QuickLinks extends React.PureComponent { this.language = window.language.widgets.quicklinks; } - updateLink(type, value) { - this.setState({ - [type]: value - }); - } - deleteLink(name, event) { event.preventDefault(); @@ -65,6 +61,23 @@ export default class QuickLinks extends React.PureComponent { } } + componentDidMount() { + EventBus.on('refresh', (data) => { + if (data === 'quicklinks') { + const element = document.querySelector('.quicklinks-container'); + + if (localStorage.getItem('quicklinksenabled') === 'false') { + return element.style.display = 'none'; + } + + element.style.display = 'block'; + this.setState({ + items: JSON.parse(localStorage.getItem('quicklinks')) + }); + } + }); + } + render() { let target, rel = null; if (localStorage.getItem('quicklinksnewtab') === 'true') { @@ -97,9 +110,9 @@ export default class QuickLinks extends React.PureComponent {

{this.language.new}

- this.updateLink('name', e.target.value)} /> + this.setState({ name: e.target.value })} />
- this.updateLink('url', e.target.value)} /> + this.setState({ url: e.target.value })} />
diff --git a/src/components/widgets/quote/Quote.jsx b/src/components/widgets/quote/Quote.jsx index 1ff3c387..a91fc96f 100644 --- a/src/components/widgets/quote/Quote.jsx +++ b/src/components/widgets/quote/Quote.jsx @@ -155,8 +155,10 @@ export default class Quote extends React.PureComponent { copy: (localStorage.getItem('copyButton') === 'false') ? null : this.buttons.copy, tweet: (localStorage.getItem('tweetButton') === 'false') ? null : this.buttons.tweet }); - - this.getQuote(); + + if (!this.state.quote) { + this.getQuote(); + } } componentDidMount() { diff --git a/src/components/widgets/weather/Weather.jsx b/src/components/widgets/weather/Weather.jsx index 8b17baae..b12e3c77 100644 --- a/src/components/widgets/weather/Weather.jsx +++ b/src/components/widgets/weather/Weather.jsx @@ -1,5 +1,7 @@ import React from 'react'; +import EventBus from '../../../modules/helpers/eventbus'; + import WeatherIcon from './WeatherIcon'; import { WiHumidity, WiWindy } from 'weather-icons-react'; @@ -13,7 +15,6 @@ export default class Weather extends React.PureComponent { icon: '', temp_text: '', weather: { - title: '', temp: '', temp_min: '', temp_max: '', @@ -25,10 +26,30 @@ export default class Weather extends React.PureComponent { } async getWeather() { - const data = await (await fetch (window.constants.WEATHER_URL + `?city=${this.state.location}`)).json(); + let data = { + weather: [ + { + icon: this.state.icon + } + ], + wind: { + speed: this.state.weather.windspeed + }, + main: { + temp: this.state.weather.original_temp, + temp_min: this.state.weather.original_temp_min, + temp_max: this.state.weather.original_temp_max, + humidity: this.state.weather.humidity, + pressure: this.state.weather.pressure + } + } + + if (!this.state.weather.temp) { + data = await (await fetch (window.constants.WEATHER_URL + `?city=${this.state.location}`)).json(); + } let temp = data.main.temp; - let temp_min = data.main.temp_max + let temp_min = data.main.temp_mix let temp_max = data.main.temp_max; let temp_text = 'K'; @@ -52,18 +73,33 @@ export default class Weather extends React.PureComponent { icon: data.weather[0].icon, temp_text: temp_text, weather: { - title: data.weather[0].main, temp: Math.round(temp), temp_min: Math.round(temp_min), temp_max: Math.round(temp_max), humidity: data.main.humidity, windspeed: data.wind.speed, - pressure: data.main.pressure + pressure: data.main.pressure, + original_temp: data.main.temp, + original_temp_min: data.main.temp_min, + original_temp_max: data.main.temp_max } }); } componentDidMount() { + EventBus.on('refresh', (data) => { + if (data === 'weather') { + const element = document.querySelector('.weather'); + + if (localStorage.getItem('weatherEnabled') === 'false') { + return element.style.display = 'none'; + } + + element.style.display = 'block'; + this.getWeather(); + } + }); + this.getWeather(); } diff --git a/src/modules/constants.js b/src/modules/constants.js index f4fe7a13..e7632142 100644 --- a/src/modules/constants.js +++ b/src/modules/constants.js @@ -1,7 +1,7 @@ export const API_URL = 'https://api.muetab.com'; export const UNSPLASH_URL = 'https://unsplash.muetab.com'; export const MARKETPLACE_URL = 'https://marketplace.muetab.com'; -export const WEATHER_URL = 'https://weather.muetab.com'; +export const WEATHER_URL = 'https://mueweather.ohlookitsderpy.workers.dev'; export const WEBSITE_URL = 'https://muetab.com'; export const SPONSORS_URL = 'https://sponsors.muetab.com'; export const GITHUB_URL = 'https://api.github.com'; diff --git a/src/modules/helpers/settings.js b/src/modules/helpers/settings.js index 37bf9040..41dee99a 100644 --- a/src/modules/helpers/settings.js +++ b/src/modules/helpers/settings.js @@ -72,7 +72,30 @@ export default class SettingsFunctions { window.location.reload(); } - static loadSettings(noeasteregg) { + static loadSettings(hotreload) { + document.getElementById('widgets').style.zoom = localStorage.getItem('widgetzoom') + '%'; + + const theme = localStorage.getItem('theme'); + switch (theme) { + case 'dark': + document.body.classList.add('dark'); + break; + case 'auto': + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + document.body.classList.add('dark'); + } + break; + default: + document.body.classList.remove('dark'); + } + + const tabName = localStorage.getItem('tabName') || window.language.tabname; + document.title = tabName; + + if (hotreload === true) { + return; + } + const css = localStorage.getItem('customcss'); if (css) { document.head.insertAdjacentHTML('beforeend', ''); @@ -106,7 +129,7 @@ export default class SettingsFunctions {