mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Share links carry the world time when made away from live
Field 28, worldTime, holds the world time of a link made away from live: zigzag seconds since 2026-01-01, like field 8, but it may lie ahead of the link's creation (a forecast moment). Opening such a link pauses the world clock at that time; a link without it leaves the clock alone, so a page opens live and Back or Forward does not stop a replay. Times no JS Date can hold are dropped.
This commit is contained in:
1 parent
0c4da3cdb2
commit
32ec6ed436
8 files changed
+96
-8
No files matched your search
+11
-2
@@ -5,6 +5,7 @@ import {
|
||||
normalizeAllocationStrategy,
|
||||
} from './data/detectionPolicy.js';
|
||||
import { clampScopeTerminusPct } from './scopeMask.js';
|
||||
import { worldClock as pageWorldClock } from './time/worldClock.js';
|
||||
import { clampScopeFeatherPct } from './scopeMaskPolicy.js';
|
||||
import {
|
||||
decodeLayerStateParams,
|
||||
@@ -68,9 +69,11 @@ export class ShareLinkManager {
|
||||
isNavigationCurrent,
|
||||
cancelOwnedNavigation,
|
||||
initialShareCode = null,
|
||||
worldClock = pageWorldClock,
|
||||
} = {},
|
||||
) {
|
||||
this.viewer = viewer;
|
||||
this._worldClock = worldClock;
|
||||
// A host may hand over the share code to open instead of the address.
|
||||
this._initialShareCode =
|
||||
typeof initialShareCode === 'string' ? initialShareCode : null;
|
||||
@@ -163,8 +166,9 @@ export class ShareLinkManager {
|
||||
|
||||
/**
|
||||
* The restore state for a share code, in the long form's parsed shape plus
|
||||
* `shareView` (what the view follows, with its offset and last-known fix),
|
||||
* or null when the code is refused.
|
||||
* `shareView` (what the view follows, with its offset and last-known fix)
|
||||
* and `worldTime` (null when the link was made live), or null when the
|
||||
* code is refused.
|
||||
*/
|
||||
_parseShareCode(code) {
|
||||
const result = decodeShareView(code);
|
||||
@@ -174,6 +178,7 @@ export class ShareLinkManager {
|
||||
}
|
||||
const state = toLegacyShareState(result.state);
|
||||
state.shareView = result.state.view;
|
||||
state.worldTime = result.state.worldTime;
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -592,6 +597,10 @@ export class ShareLinkManager {
|
||||
// that state in the share format.
|
||||
const state = fromLegacyShareState(this._parseShareHash(params.toString()));
|
||||
state.sharedAtMs = Math.floor(nowMs / 1000) * 1000;
|
||||
// Away from live, the link opens at the same world time.
|
||||
state.worldTime = this._worldClock.isLive()
|
||||
? null
|
||||
: Math.floor(this._worldClock.now() / 1000) * 1000;
|
||||
let subject = null;
|
||||
try {
|
||||
subject = this._followSubjectProvider?.({ nowMs }) ?? null;
|
||||
|
||||
Reference in new issue
Block a user