From 66a3629b5196bb0250490f1d1e08b5c7cc25c690 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Fri, 10 Sep 2021 19:33:56 +0100 Subject: [PATCH] fix: photo information undefined text --- src/components/widgets/background/Background.jsx | 6 ------ .../widgets/background/PhotoInformation.jsx | 14 +++++++------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/components/widgets/background/Background.jsx b/src/components/widgets/background/Background.jsx index 8c75b313..e1b74ba5 100644 --- a/src/components/widgets/background/Background.jsx +++ b/src/components/widgets/background/Background.jsx @@ -1,5 +1,4 @@ // todo: rewrite this mess -import variables from 'modules/variables'; import { PureComponent } from 'react'; import PhotoInformation from './PhotoInformation'; @@ -134,15 +133,10 @@ export default class Background extends PureComponent { let credit = data.photographer; let photoURL, photographerURL; - const language = variables.language; - const languagecode = variables.languagecode; - if (backgroundAPI === 'unsplash') { - credit = data.photographer + ` ${language.getMessage(languagecode, 'background.unsplash')}`; photoURL = data.photo_page; photographerURL = data.photographer_page; } else if (backgroundAPI === 'pexels') { - credit = data.photographer + ` ${language.getMessage(languagecode, 'background.pexels')}`; photoURL = data.photo_page; photographerURL = data.photographer_page; } diff --git a/src/components/widgets/background/PhotoInformation.jsx b/src/components/widgets/background/PhotoInformation.jsx index d94e5d37..74ae0b69 100644 --- a/src/components/widgets/background/PhotoInformation.jsx +++ b/src/components/widgets/background/PhotoInformation.jsx @@ -36,17 +36,17 @@ export default function PhotoInformation({ info, url, api }) { const pexels = variables.language.getMessage(variables.languagecode, 'widgets.background.pexels'); const photographer = info.credit.split(` ${unsplash}`)[0].split(` ${pexels}`); - let credit; - let photo; + let credit = info.credit; + let photo = variables.language.getMessage(variables.languagecode, 'widgets.background.credit'); // unsplash and pexels credit if (info.photographerURL && info.photographerURL !== '' && !info.offline && api) { if (api === 'unsplash') { - photo = {variables.language.getMessage(variables.languagecode, 'widgets.background.credit')}; - credit = <>{photographer} {unsplash}; + photo = {photo}; + credit = <>{info.credit} {unsplash}; } else { - photo = {variables.language.getMessage(variables.languagecode, 'widgets.background.credit')}; - credit = <>{photographer} {pexels}; + photo = {photo}; + credit = <>{info.credit} {pexels}; } } @@ -142,7 +142,7 @@ export default function PhotoInformation({ info, url, api }) { {width}x{height} - {info.credit} + {photographer} {downloadEnabled ? <>