From 655d400fde0ccc7710f9c889ae6f274a3fb0c44c Mon Sep 17 00:00:00 2001 From: someCatInTheWorld <162684669+someCatInTheWorld@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:35:00 +1100 Subject: [PATCH] merge-upstream: Revert server API changes that aren't applicable with our current API. * Also try to fix HomeCommunication, but we can't really test this until we merge this. --- src/containers/home-communication.jsx | 13 ++----------- src/lib/tw-project-meta-fetcher-hoc.jsx | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/containers/home-communication.jsx b/src/containers/home-communication.jsx index 79b6e2721e0..567ce4f1e96 100644 --- a/src/containers/home-communication.jsx +++ b/src/containers/home-communication.jsx @@ -21,12 +21,7 @@ class HomeCommunication extends React.Component { componentDidMount() { window.addEventListener('message', this.wrapperEventHandler); - const iframe = document.createElement('iframe'); - iframe.src = `${origin}/embed/editor?external=${encodeURIComponent(window.origin)}`; - iframe.width = 100; - iframe.height = 100; - iframe.style.display = 'none'; - document.body.appendChild(iframe); + const iframe = document.getElementById('login'); this.setState({ frame: iframe @@ -34,10 +29,6 @@ class HomeCommunication extends React.Component { } componentWillUnmount() { window.removeEventListener('message', this.wrapperEventHandler); - const iframe = this.state.frame; - if (iframe) { - iframe.remove(); - } this.setState({ frame: null }); @@ -46,7 +37,7 @@ class HomeCommunication extends React.Component { async wrapperEventHandler(e) { const data = e.data; // Don't recursively try to run this event. - if (e.origin === window.origin) { + if (e.origin !== 'https://www.snail-ide.com') { return; } if (!data.type) return; diff --git a/src/lib/tw-project-meta-fetcher-hoc.jsx b/src/lib/tw-project-meta-fetcher-hoc.jsx index 0782c4bf751..113e8e53c1a 100644 --- a/src/lib/tw-project-meta-fetcher-hoc.jsx +++ b/src/lib/tw-project-meta-fetcher-hoc.jsx @@ -127,18 +127,18 @@ const TWProjectMetaFetcherHOC = function (WrappedComponent) { // this is a remix, find the original project fetchProjectMeta(rawData.remix) .then(remixProject => { - // If project ID changed, ignore the results. - if (this.props.projectId !== projectId) { - return; + // If this project is hidden or not approved, ignore the results. + if ( + typeof remixProject.name === 'string' + || typeof remixProject.owner === 'string' + ) { + this.props.onSetRemixedProjectInfo( + true, // loaded + remixProject.name, + remixProject.owner + ); } - - this.props.onSetRemixedProjectInfo( - true, // loaded - remixProject.title, - remixProject.author.username - ); - }) - .catch(err => { + }).catch(err => { // this isnt fatal, just log log.warn('cannot fetch remixed project meta for this project;', err); });