From c8c92aa45da5a4ca0fe9fd043ebc01ac0fbba550 Mon Sep 17 00:00:00 2001 From: Julian Rubisch Date: Mon, 8 Jul 2024 13:06:35 +0200 Subject: [PATCH] chore: Use sessionStorage to store requested turbo frame --- javascript/elements/futurism_utils.js | 2 +- javascript/elements/index.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/javascript/elements/futurism_utils.js b/javascript/elements/futurism_utils.js index eed5c16..d23100d 100644 --- a/javascript/elements/futurism_utils.js +++ b/javascript/elements/futurism_utils.js @@ -1,7 +1,7 @@ /* global IntersectionObserver, CustomEvent, setTimeout */ const dispatchAppearEvent = (entry, observer = null) => { - if (!window.Futurism) { + if (!window.Futurism?.subscription) { return () => { setTimeout(() => dispatchAppearEvent(entry, observer)(), 1) } diff --git a/javascript/elements/index.js b/javascript/elements/index.js index a8f20ea..cc3077c 100644 --- a/javascript/elements/index.js +++ b/javascript/elements/index.js @@ -60,8 +60,8 @@ const restorePlaceholders = e => { // if the TF request has been promoted to an advance action // (data-turbo-action="advance"), this callback will fire inadvertently // but the whole page will not be exchanged as in a regular TD visit - if (window.Futurism.requestedTurboFrame) { - delete window.Futurism.requestedTurboFrame + if (sessionStorage.getItem('requested-turbo-frame')) { + delete sessionStorage.removeItem('requested-turbo-frame') return } @@ -87,7 +87,7 @@ const storeRequestedTurboFrame = e => { if (!headers['Turbo-Frame'] || headers['X-Sec-Purpose'] === 'prefetch') return // we store the frame ID in case the incoming request was referencing one - window.Futurism.requestedTurboFrame = headers['Turbo-Frame'] + sessionStorage.setItem('requested-turbo-frame', headers['Turbo-Frame']) } export const initializeElements = () => {