diff --git a/src/react-components/scene-ui.js b/src/react-components/scene-ui.js index 29d9dbde78..73e330d862 100644 --- a/src/react-components/scene-ui.js +++ b/src/react-components/scene-ui.js @@ -7,9 +7,10 @@ import configs from "../utils/configs"; import { createAndRedirectToNewHub, getReticulumFetchUrl } from "../utils/phoenix-utils"; import { ReactComponent as CodeBranch } from "./icons/CodeBranch.svg"; import { ReactComponent as Pen } from "./icons/Pen.svg"; -import { ReactComponent as Twitter } from "./icons/Twitter.svg"; +import { ReactComponent as ShareIcon } from "./icons/Share.svg"; import IfFeature from "./if-feature"; import { AppLogo } from "./misc/AppLogo"; +import { share } from "../utils/share"; class SceneUI extends Component { static propTypes = { @@ -61,9 +62,13 @@ class SceneUI extends Component { shareHashtag: configs.translation("share-hashtag") } ); - const tweetLink = `https://twitter.com/share?url=${encodeURIComponent(sceneUrl)}&text=${encodeURIComponent( - tweetText - )}`; + const onShareClick = async (_event) => { + try { + await share({ url: sceneUrl, title: tweetText }); + } catch (error) { + console.error(`while sharing (from scene UI):`, error) + } + }; const unknown = intl.formatMessage({ id: "scene-page.unknown", defaultMessage: "unknown" }); @@ -235,12 +240,10 @@ class SceneUI extends Component { ) )} - - -
- -
-
+
diff --git a/src/utils/share.js b/src/utils/share.js index 1699254e35..77e3846f72 100644 --- a/src/utils/share.js +++ b/src/utils/share.js @@ -1,4 +1,4 @@ -const isMobileVR = AFRAME.utils.device.isMobileVR(); +const isMobileVR = window?.AFRAME?.utils?.device?.isMobileVR(); export function canShare() { // TODO, fix up when OB/FxR support sharing