From 4a6f93e701eb41f81c7a8070c93db654ce242a01 Mon Sep 17 00:00:00 2001 From: Wessel Date: Thu, 11 Nov 2021 15:26:25 +0100 Subject: [PATCH] refractor(widgets): Change one-lined if statements --- src/components/widgets/background/Background.jsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/widgets/background/Background.jsx b/src/components/widgets/background/Background.jsx index 07d8e876..7d12d21c 100644 --- a/src/components/widgets/background/Background.jsx +++ b/src/components/widgets/background/Background.jsx @@ -30,15 +30,16 @@ export default class Background extends PureComponent { const backgroundImage = document.getElementById('backgroundImage'); if (this.state.url !== '') { - const url = (localStorage.getItem('ddgProxy') === 'true' && this.state.photoInfo.offline !== true && !this.state.url.startsWith('data:')) ? variables.constants.DDG_IMAGE_PROXY + this.state.url : this.state.url; + let url = this.state.url; + if (localStorage.getItem('ddgProxy') === 'true' && this.state.photoInfo.offline !== true && !this.state.url.startsWith('data:')) { + url = variables.constants.DDG_IMAGE_PROXY + this.state.url; + } + const photoInformation = document.querySelector('.photoInformation'); // just set the background if (localStorage.getItem('bgtransition') === 'false') { - if (photoInformation) { - photoInformation.style.display = 'block'; - } - backgroundImage.style.background = null; + photoInformation?.[photoInformation.style.display = 'block']; return backgroundImage.style.background = `url(${url})`; } @@ -47,9 +48,7 @@ export default class Background extends PureComponent { backgroundImage.style.background = null; // same with photo information if not using custom background - if (photoInformation) { - photoInformation.classList.add('backgroundPreload'); - } + photoInformation?.classList.add('backgroundPreload'); // preloader for background transition, required so it loads in nice const preloader = document.createElement('img');