fix: various bug fixes and refactor search settings

This commit is contained in:
David Ralph
2021-04-10 19:36:58 +01:00
parent dad43e969f
commit f4de44bbbb
11 changed files with 85 additions and 85 deletions

View File

@@ -22,20 +22,7 @@ export default class Widgets extends React.PureComponent {
}
enabled(key) {
const stringValue = localStorage.getItem(key);
let enabled = true;
if (stringValue !== null) {
if (stringValue === 'true') {
enabled = true;
}
if (stringValue === 'false') {
enabled = false;
}
}
return enabled;
return (localStorage.getItem(key) === 'true');
}
componentDidMount() {

View File

@@ -226,12 +226,12 @@ export default class Background extends React.PureComponent {
render() {
if (this.state.video === true) {
const checkValue = (setting) => {
const enabled = (setting) => {
return (localStorage.getItem(setting) === 'true');
};
return (
<video autoPlay muted={checkValue('backgroundVideoMute')} loop={checkValue('backgroundVideoLoop')} id='backgroundVideo'>
<video autoPlay muted={enabled('backgroundVideoMute')} loop={enabled('backgroundVideoLoop')} id='backgroundVideo'>
<source src={this.state.url}/>
</video>
);

View File

@@ -91,7 +91,7 @@ export default class Clock extends React.PureComponent {
render() {
let clockHTML = <h1 className='clock'>{this.state.time}<span className='ampm'>{this.state.ampm}</span></h1>;
const checkValue = (setting) => {
const enabled = (setting) => {
return (localStorage.getItem(setting) === 'true');
};
@@ -100,11 +100,11 @@ export default class Clock extends React.PureComponent {
<Analog
className='analogclock'
value={this.state.time}
renderHourMarks={checkValue('hourMarks')}
renderMinuteMarks={checkValue('minuteMarks')}
renderSecondHand={checkValue('secondHand')}
renderMinuteHand={checkValue('minuteHand')}
renderHourHand={checkValue('hourHand')}
renderHourMarks={enabled('hourMarks')}
renderMinuteMarks={enabled('minuteMarks')}
renderSecondHand={enabled('secondHand')}
renderMinuteHand={enabled('minuteHand')}
renderHourHand={enabled('hourHand')}
/>
);
}

View File

@@ -68,7 +68,7 @@ export default class Weather extends React.PureComponent {
}
render() {
const checkValue = (setting) => {
const enabled = (setting) => {
return (localStorage.getItem(setting) === 'true');
};
@@ -92,12 +92,11 @@ export default class Weather extends React.PureComponent {
<WeatherIcon name={this.state.icon}/>
<span>{this.state.weather.temp + this.state.temp_text}</span>
<span className='minmax'>{minmax()}</span>
{checkValue('humidity') ? <span className='loc'><br/><WiHumidity/>{this.state.weather.humidity}%</span> : null}
{checkValue('windspeed') ? <span className='loc'><br/><WiWindy/>{this.state.weather.windspeed}<span className='minmax'> m/s</span></span> : null}
{checkValue('atmosphericpressure') ? <span className='loc'><br/>{this.state.weather.pressure}<span className='minmax'> hPa</span></span> : null}
{enabled('humidity') ? <span className='loc'><br/><WiHumidity/>{this.state.weather.humidity}%</span> : null}
{enabled('windspeed') ? <span className='loc'><br/><WiWindy/>{this.state.weather.windspeed}<span className='minmax'> m/s</span></span> : null}
{enabled('atmosphericpressure') ? <span className='loc'><br/>{this.state.weather.pressure}<span className='minmax'> hPa</span></span> : null}
<br/>
<span className='loc'>{this.state.location}</span>
{/*<span>{this.state.weather.title}</span>*/}
</div>
);
}