mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 17:22:19 +00:00
refactor(imagery): drop unused cancellation counters and impossible-case guards
This commit is contained in:
1 parent
a0db300d54
commit
bd84fab552
3 files changed
+8
-33
No files matched your search
@@ -580,7 +580,7 @@ export function createRecentImageryLayer({
|
||||
firstVisible: _visible.first,
|
||||
lastVisible: _visible.last,
|
||||
extra: 2,
|
||||
}) || [],
|
||||
}),
|
||||
);
|
||||
for (const key of new Set([
|
||||
_assigned.a,
|
||||
@@ -593,7 +593,7 @@ export function createRecentImageryLayer({
|
||||
thumbnails.request(candidate, _box, 0);
|
||||
wanted.add(candidate.key);
|
||||
}
|
||||
thumbnails.retain?.(wanted);
|
||||
thumbnails.retain(wanted);
|
||||
}
|
||||
|
||||
function resetCatalog() {
|
||||
|
||||
@@ -37,8 +37,6 @@ export function createThumbnailLoader({
|
||||
const queue = [];
|
||||
let inFlight = 0;
|
||||
let touchCounter = 0;
|
||||
let supersededQueued = 0;
|
||||
let supersededInFlight = 0;
|
||||
let destroyed = false;
|
||||
|
||||
function notify(key) {
|
||||
@@ -225,14 +223,10 @@ export function createThumbnailLoader({
|
||||
candidates.length,
|
||||
extra,
|
||||
);
|
||||
const keys = [];
|
||||
order.forEach((index, priority) => {
|
||||
const candidate = candidates[index];
|
||||
if (!candidate?.key) return;
|
||||
keys.push(candidate.key);
|
||||
this.request(candidate, box, priority);
|
||||
return order.map((index, priority) => {
|
||||
this.request(candidates[index], box, priority);
|
||||
return candidates[index].key;
|
||||
});
|
||||
return keys;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -242,19 +236,16 @@ export function createThumbnailLoader({
|
||||
* @param {Iterable<string>} keys
|
||||
*/
|
||||
retain(keys) {
|
||||
const wanted = new Set(keys || []);
|
||||
const wanted = new Set(keys);
|
||||
for (let index = queue.length - 1; index >= 0; index -= 1) {
|
||||
const entry = queue[index];
|
||||
if (wanted.has(entry.key)) continue;
|
||||
queue.splice(index, 1);
|
||||
supersededQueued += 1;
|
||||
if (entry.status === 'unknown') entries.delete(entry.key);
|
||||
}
|
||||
for (const entry of [...entries.values()]) {
|
||||
if (!entry.loading || wanted.has(entry.key)) continue;
|
||||
if (!entry.controller || entry.controller.signal.aborted) continue;
|
||||
entry.controller.abort();
|
||||
supersededInFlight += 1;
|
||||
entry.controller?.abort();
|
||||
if (entry.status === 'unknown') entries.delete(entry.key);
|
||||
}
|
||||
},
|
||||
@@ -301,13 +292,6 @@ export function createThumbnailLoader({
|
||||
return () => listeners.delete(listener);
|
||||
},
|
||||
|
||||
refinementStats() {
|
||||
return {
|
||||
supersededQueued,
|
||||
supersededInFlight,
|
||||
};
|
||||
},
|
||||
|
||||
stats() {
|
||||
return {
|
||||
inFlight,
|
||||
|
||||
@@ -357,14 +357,10 @@ test('retain aborts stale acquisition while allowing the current intent to start
|
||||
'current intent starts after stale abort',
|
||||
);
|
||||
assert.match(fetch.calls[1].url, /TIME=2026-09-11/);
|
||||
assert.deepEqual(loader.refinementStats(), {
|
||||
supersededQueued: 0,
|
||||
supersededInFlight: 1,
|
||||
});
|
||||
assert.equal(loader.get(stale.key).status, 'unknown');
|
||||
});
|
||||
|
||||
test('repeat retain counts an aborted known-present re-fetch once', async () => {
|
||||
test('a cancelled re-fetch of a known-present day keeps its status and is retryable', async () => {
|
||||
const { loader, fetch } = fixture({ maxInFlight: 1, maxDecoded: 1 });
|
||||
const stale = candidate('S30', '2026-09-10');
|
||||
const newer = candidate('S30', '2026-09-11');
|
||||
@@ -383,12 +379,7 @@ test('repeat retain counts an aborted known-present re-fetch once', async () =>
|
||||
loader.request(stale, BOX, 0);
|
||||
assert.equal(fetch.calls.length, 3, 'an evicted known day re-fetches');
|
||||
loader.retain([]);
|
||||
loader.retain([]);
|
||||
assert.equal(fetch.calls[2].signal.aborted, true);
|
||||
assert.deepEqual(loader.refinementStats(), {
|
||||
supersededQueued: 0,
|
||||
supersededInFlight: 1,
|
||||
});
|
||||
|
||||
await settle();
|
||||
assert.equal(loader.get(stale.key).status, 'present');
|
||||
|
||||
Reference in new issue
Block a user