mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Keep the place search, language listener, logo gaze and Google key for the page session
An engine switch no longer recreates them: with a layer session they live until the page lifetime aborts; a host without one keeps the per-application lifetime.
This commit is contained in:
1 parent
f0c2523ac4
commit
35ed499ae4
2 files changed
+55
-22
No files matched your search
+21
-9
@@ -39,15 +39,27 @@ export async function createApplicationScene({
|
||||
signal: layerSession?.lifetime.signal ?? signal,
|
||||
});
|
||||
if (layerSession) layerSession.operations = operations;
|
||||
defer(initLogoGaze());
|
||||
const previousKey = window.__GOOGLE_MAPS_API_KEY__;
|
||||
if (googleApiKey) {
|
||||
window.__GOOGLE_MAPS_API_KEY__ = googleApiKey;
|
||||
defer(() => {
|
||||
if (window.__GOOGLE_MAPS_API_KEY__ !== googleApiKey) return;
|
||||
if (previousKey === undefined) delete window.__GOOGLE_MAPS_API_KEY__;
|
||||
else window.__GOOGLE_MAPS_API_KEY__ = previousKey;
|
||||
});
|
||||
// The logo's gaze and the page's Google key belong to the page session
|
||||
// when there is one: an engine switch keeps them.
|
||||
const pageChrome = layerSession ? (layerSession.chrome ??= {}) : null;
|
||||
const own = pageChrome
|
||||
? (release) =>
|
||||
layerSession.lifetime.signal.addEventListener('abort', release, {
|
||||
once: true,
|
||||
})
|
||||
: defer;
|
||||
if (!pageChrome?.sceneChrome) {
|
||||
if (pageChrome) pageChrome.sceneChrome = true;
|
||||
own(initLogoGaze());
|
||||
const previousKey = window.__GOOGLE_MAPS_API_KEY__;
|
||||
if (googleApiKey) {
|
||||
window.__GOOGLE_MAPS_API_KEY__ = googleApiKey;
|
||||
own(() => {
|
||||
if (window.__GOOGLE_MAPS_API_KEY__ !== googleApiKey) return;
|
||||
if (previousKey === undefined) delete window.__GOOGLE_MAPS_API_KEY__;
|
||||
else window.__GOOGLE_MAPS_API_KEY__ = previousKey;
|
||||
});
|
||||
}
|
||||
}
|
||||
// A cached renderer is built once, by the first application that asks for
|
||||
// its engine, and later applications reuse it warm. Everything this closure
|
||||
|
||||
Reference in new issue
Block a user