Skip to content

Commit 331b54b

Browse files
committed
Add handling for new scheme and simplify legacy fallback logic
1 parent a3b91f9 commit 331b54b

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

client/my-sites/customer-home/components/home-content/studio-deeplink.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,14 @@ const openSyncUrlInStudio = ( studioSiteId: string, siteId: number ) => {
1010
const legacySchemeUrl = `${ STUDIO_URL_SCHEME_LEGACY }://${ path }`;
1111

1212
// Use new scheme for new Studio app versions.
13-
window.location.href = newSchemeUrl;
13+
try {
14+
window.location.href = newSchemeUrl;
15+
} catch ( error ) {}
1416

15-
// Also try legacy scheme in a hidden iframe as fallback for old Studio app versions.
16-
const iframe = document.createElement( 'iframe' );
17-
iframe.style.display = 'none';
18-
iframe.src = legacySchemeUrl;
19-
document.body.appendChild( iframe );
20-
21-
// Clean up the iframe after a short delay
17+
// Fallback to legacy scheme for old Studio app versions. It will be blocked by the browser
18+
// if scheme is not registered.
2219
setTimeout( () => {
23-
if ( iframe.parentNode ) {
24-
iframe.parentNode.removeChild( iframe );
25-
}
20+
window.location.href = legacySchemeUrl;
2621
}, 1000 );
2722
};
2823

0 commit comments

Comments
 (0)