mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-13 06:42:23 +00:00
Let a newer share switch off a library layer still switching on
A share restore skipped every entry whose settled state already matched the share, but a layer still switching on for an earlier share reads as off until it settles. Opening a second share in that window left the first share's layer to come on anyway. The restore now compares with the manager's effective visibility (the newest request), so the newer share supersedes the earlier one.
This commit is contained in:
1 parent
d58ba23fba
commit
0f13c0a1c2
2 files changed
+35
-1
No files matched your search
@@ -204,7 +204,12 @@ export function createDataLibrary({
|
|||||||
if (wanted && !register(entry)) continue;
|
if (wanted && !register(entry)) continue;
|
||||||
if (!isRegistered(id)) continue;
|
if (!isRegistered(id)) continue;
|
||||||
const layerId = libraryLayerId(id);
|
const layerId = libraryLayerId(id);
|
||||||
if (wanted === (dataManager.isEnabled?.(layerId) === true)) continue;
|
// Compare with the newest request, not settled state: a layer still
|
||||||
|
// switching on for an earlier share must be switched off by this one.
|
||||||
|
const current =
|
||||||
|
dataManager.isEffectivelyEnabled?.(layerId) ??
|
||||||
|
dataManager.isEnabled?.(layerId);
|
||||||
|
if (wanted === (current === true)) continue;
|
||||||
dataManager
|
dataManager
|
||||||
.setEnabled(layerId, wanted, { origin })
|
.setEnabled(layerId, wanted, { origin })
|
||||||
.catch((error) =>
|
.catch((error) =>
|
||||||
|
|||||||
@@ -316,6 +316,35 @@ test('navigating between shares switches library entries on and off', async (t)
|
|||||||
assert.equal(shareLink.listener, null);
|
assert.equal(shareLink.listener, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a share opened while an earlier one is still switching on wins', async (t) => {
|
||||||
|
const manager = sealedManager(t);
|
||||||
|
const shareLink = fakeShareLink(null);
|
||||||
|
const library = createDataLibrary({
|
||||||
|
entries,
|
||||||
|
ledger,
|
||||||
|
dataManager: manager,
|
||||||
|
services: {},
|
||||||
|
storage: memoryStorage(),
|
||||||
|
shareLink,
|
||||||
|
source: source({}),
|
||||||
|
});
|
||||||
|
await library.start();
|
||||||
|
const settle = () =>
|
||||||
|
Promise.all(
|
||||||
|
['lib-night-lights', 'lib-sea-marks'].map((id) =>
|
||||||
|
manager.waitForLayerSettled?.(id),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
// Neither share waits for the one before it to settle.
|
||||||
|
shareLink.listener(['00']);
|
||||||
|
assert.equal(manager.isEnabled('lib-night-lights'), false, 'still enabling');
|
||||||
|
shareLink.listener(['01']);
|
||||||
|
await settle();
|
||||||
|
assert.equal(manager.isEnabled('lib-night-lights'), false);
|
||||||
|
assert.equal(manager.isEnabled('lib-sea-marks'), true);
|
||||||
|
library.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
test('zoom flies to an added layer through the caller, reset removes everything', async (t) => {
|
test('zoom flies to an added layer through the caller, reset removes everything', async (t) => {
|
||||||
const manager = sealedManager(t);
|
const manager = sealedManager(t);
|
||||||
const storage = memoryStorage();
|
const storage = memoryStorage();
|
||||||
|
|||||||
Reference in new issue
Block a user