From 693aa1aa9333839e0d2ebc1933c4124e9b7d1d58 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Sat, 10 Oct 2020 15:26:48 +0100 Subject: [PATCH] Fix custom background colour and images not working on offline mode --- src/components/widgets/Background.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/widgets/Background.jsx b/src/components/widgets/Background.jsx index 786ba226..68992a80 100644 --- a/src/components/widgets/Background.jsx +++ b/src/components/widgets/Background.jsx @@ -36,7 +36,7 @@ export default class Background extends React.PureComponent { } async determineMode() { - if (localStorage.getItem('offlineMode') === 'true') return this.doOffline(); + const offlineMode = localStorage.getItem('offlineMode'); const photoPack = JSON.parse(localStorage.getItem('photo_packs')); const customBackgroundColour = localStorage.getItem('customBackgroundColour'); @@ -44,10 +44,12 @@ export default class Background extends React.PureComponent { const favourited = JSON.parse(localStorage.getItem('favourite')); if (favourited) { + if (offlineMode === 'true') return this.doOffline(); this.setBackground(favourited.url, null, 'true'); this.setCredit(favourited.credit); document.getElementById('location').textContent = favourited.location; } else if (photoPack) { + if (offlineMode === 'true') return this.doOffline(); const randomPhoto = photoPack[Math.floor(Math.random() * photoPack.length)]; this.setBackground(randomPhoto.url.default, null, randomPhoto.photographer); this.setCredit(randomPhoto.photographer); @@ -57,6 +59,7 @@ export default class Background extends React.PureComponent { } else if (customBackground !== '') { // Local this.setBackground(customBackground, null, 'false'); } else { // Online + if (offlineMode === 'true') return this.doOffline(); try { // First we try and get an image from the API... const enabled = localStorage.getItem('webp'); let requestURL;