mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 16:52:20 +00:00
Stop sharing a Data Library entry as on once its failed Remove switched it off
When Remove switched a layer off and then its destroy failed, the manager published no visibility change, so the selection still listed the entry as on: the link shared it as on and a reload restored it on while its row read off. A failed Remove now drops the entry from what is on and remembered whenever its layer ended up off.
This commit is contained in:
1 parent
837eff7328
commit
8cca78bcd5
2 files changed
+47
-1
No files matched your search
@@ -581,6 +581,41 @@ test('the URL keeps the opening lib= before availability loads and for entries i
|
||||
library.destroy();
|
||||
});
|
||||
|
||||
test('a layer switched off before its teardown failed is no longer shared as on', async (t) => {
|
||||
const manager = sealedManager(t);
|
||||
const storage = memoryStorage();
|
||||
const shareLink = shareLinkDouble();
|
||||
const library = createDataLibrary({
|
||||
entries,
|
||||
ledger,
|
||||
dataManager: manager,
|
||||
services: {},
|
||||
storage,
|
||||
shareLink,
|
||||
initialHash: '',
|
||||
source: source({}),
|
||||
});
|
||||
await library.start();
|
||||
await library.add('night-lights');
|
||||
assert.equal(shareLink.encode(), '00');
|
||||
const { module } = manager.layers.get('lib-night-lights');
|
||||
const destroy = module.destroy;
|
||||
module.destroy = async () => {
|
||||
throw new Error('stuck');
|
||||
};
|
||||
t.mock.method(console, 'warn', () => {});
|
||||
try {
|
||||
assert.equal(await library.remove('night-lights'), false);
|
||||
assert.equal(manager.isEnabled('lib-night-lights'), false);
|
||||
assert.equal(shareLink.encode(), null);
|
||||
const saved = JSON.parse(storage.store.get(LIBRARY_STORAGE_KEY));
|
||||
assert.deepEqual(saved, { added: ['night-lights'], on: [] });
|
||||
} finally {
|
||||
module.destroy = destroy;
|
||||
}
|
||||
library.destroy();
|
||||
});
|
||||
|
||||
test('zoom flies to an added layer through the caller, reset removes everything', async (t) => {
|
||||
const manager = sealedManager(t);
|
||||
const storage = memoryStorage();
|
||||
|
||||
Reference in new issue
Block a user