From 3814010e7a7ced8f4cb3dd946a21940bece95dc1 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Fri, 17 Feb 2023 15:25:04 +0000 Subject: [PATCH] fix: favourite, share modal, reminder etc --- .../helpers/notification/notification.jsx | 18 ----------- .../helpers/sharemodal/ShareModal.jsx | 31 +++++++++++-------- .../modals/main/tabs/backend/Tabs.jsx | 7 ++++- .../widgets/background/Background.jsx | 13 +++++--- .../widgets/background/Favourite.jsx | 4 ++- .../widgets/background/PhotoInformation.jsx | 2 +- 6 files changed, 37 insertions(+), 38 deletions(-) delete mode 100644 src/components/helpers/notification/notification.jsx diff --git a/src/components/helpers/notification/notification.jsx b/src/components/helpers/notification/notification.jsx deleted file mode 100644 index a94fb5d4..00000000 --- a/src/components/helpers/notification/notification.jsx +++ /dev/null @@ -1,18 +0,0 @@ -import { memo } from 'react'; - -import variables from 'modules/variables'; -import './preview.scss'; - -function Notification(props) { - return ( -
- {variables.getMessage('modals.main.settings.reminder.title')} - {variables.getMessage('modals.welcome.preview.description')} - -
- ); -} - -export default memo(Notification); diff --git a/src/components/helpers/sharemodal/ShareModal.jsx b/src/components/helpers/sharemodal/ShareModal.jsx index e9e26347..96c78838 100644 --- a/src/components/helpers/sharemodal/ShareModal.jsx +++ b/src/components/helpers/sharemodal/ShareModal.jsx @@ -10,18 +10,23 @@ import { toast } from 'react-toastify'; import './sharemodal.scss'; function ShareModal({ modalClose, data }) { + if (data.startsWith('https://cdn.')) { + data = { + url: data, + name: 'this image', + }; + } else { + data = { + url: data, + name: 'this marketplace item', + }; + } + const copyLink = () => { - navigator.clipboard.writeText(data); + navigator.clipboard.writeText(data.url); toast(variables.getMessage('modals.share.copy_link')); }; - // look into what's wrong with this - try { - if (!data.data) { - data.data.name = 'this image'; - } - } catch (e) {} - return (
@@ -38,7 +43,7 @@ function ShareModal({ modalClose, data }) { onClick={() => window .open( - `https://twitter.com/intent/tweet?text=Check out ${data.name} on @getmue: ${data}`, + `https://twitter.com/intent/tweet?text=Check out ${data.name} on @getmue: ${data.url}`, '_blank', ) .focus() @@ -50,7 +55,7 @@ function ShareModal({ modalClose, data }) {
- +
diff --git a/src/components/widgets/background/Background.jsx b/src/components/widgets/background/Background.jsx index ca707a56..0469e992 100644 --- a/src/components/widgets/background/Background.jsx +++ b/src/components/widgets/background/Background.jsx @@ -37,7 +37,9 @@ export default class Background extends PureComponent { async setBackground() { // clean up the previous image to prevent a memory leak - if (this.state.blob) URL.revokeObjectURL(this.state.blob); + if (this.blob) { + URL.revokeObjectURL(this.blob); + } const backgroundImage = document.getElementById('backgroundImage'); @@ -74,9 +76,9 @@ export default class Background extends PureComponent { backgroundImage.style.backgroundImage = `url(${canvas.toDataURL()})`; } - this.state.blob = URL.createObjectURL(await (await fetch(url)).blob()); + this.blob = URL.createObjectURL(await (await fetch(url)).blob()); backgroundImage.classList.add('backgroundTransform'); - backgroundImage.style.backgroundImage = `url(${this.state.blob})`; + backgroundImage.style.backgroundImage = `url(${this.blob})`; } else { // custom colour backgroundImage.setAttribute('style', this.state.style); @@ -165,7 +167,7 @@ export default class Background extends PureComponent { offline = true; } - const setFavourited = ({ type, url, credit, location, camera }) => { + const setFavourited = ({ type, url, credit, location, camera, pun, offline }) => { if (type === 'random_colour' || type === 'random_gradient') { return this.setState({ type: 'colour', @@ -178,6 +180,9 @@ export default class Background extends PureComponent { credit, location, camera, + pun, + offline, + url, }, }); }; diff --git a/src/components/widgets/background/Favourite.jsx b/src/components/widgets/background/Favourite.jsx index 7a5cab55..29b5f3a8 100644 --- a/src/components/widgets/background/Favourite.jsx +++ b/src/components/widgets/background/Favourite.jsx @@ -77,10 +77,12 @@ export default class Favourite extends PureComponent { JSON.stringify({ type, url, - credit: document.getElementById('credit').textContent || '', + credit: this.props.credit || '', location: location?.innerText, camera: camera?.innerText, resolution: document.getElementById('infoResolution').textContent || '', + offline: this.props.offline, + pun: this.props.pun, }), ); } diff --git a/src/components/widgets/background/PhotoInformation.jsx b/src/components/widgets/background/PhotoInformation.jsx index 4043e075..b0a8aa59 100644 --- a/src/components/widgets/background/PhotoInformation.jsx +++ b/src/components/widgets/background/PhotoInformation.jsx @@ -364,7 +364,7 @@ function PhotoInformation({ info, url, api }) { key="favourite" placement="top" > - + {!info.offline ? (