mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
Recent Imagery: drape the next ranked day when the automatic day is empty
When the automatic day probes empty, pruneEmpty() hands it over to the next ranked day and follows that day until its probe answers. The thumbnail subscriber previews a followed day only while it is focused, but focus did not move with the hand-over: autoPreview() sets focus only when there is none, and reconcileFocus() moves focus off a hidden card to the nearest card, not to the next ranked day. With empty days shown, focus stayed on the empty day; with them hidden, it could land on an older neighbour. Either way the successor probed present and never reached the map. autoPreview() now takes the empty automatic day, and focus still on it moves to the successor. Focus the user moved elsewhere stays put. Two layer tests cover both cases; both fail without the change.
This commit is contained in:
1 parent
42540ad85e
commit
def87c4dc0
3 files changed
+38
-6
No files matched your search
@@ -285,12 +285,17 @@ export function createRecentImageryLayer({
|
||||
const rank = (list) =>
|
||||
rankLatest(list.map(withAvailability), { truncated: _truncated });
|
||||
|
||||
/** Focus the START HERE day and preview it when the mode's slot is empty. */
|
||||
function autoPreview() {
|
||||
/**
|
||||
* Focus the START HERE day and preview it when the mode's slot is empty.
|
||||
* @param {string | null} [emptyKey] The empty automatic day handed over;
|
||||
* focus still on it moves too, since a followed day previews only while
|
||||
* it is focused.
|
||||
*/
|
||||
function autoPreview(emptyKey = null) {
|
||||
const ranked = rank(sourcedCandidates());
|
||||
if (!ranked.candidate) return;
|
||||
const key = ranked.candidate.key;
|
||||
if (!_focusKey) _focusKey = key;
|
||||
if (!_focusKey || _focusKey === emptyKey) _focusKey = key;
|
||||
if (!previewSlot() || activeSlotOf(key)) return;
|
||||
_auto = { key, reason: ranked.reason, certain: ranked.certain };
|
||||
if (drapable(candidateFor(key))) _previewKey = key;
|
||||
@@ -317,7 +322,7 @@ export function createRecentImageryLayer({
|
||||
_previewKey = null;
|
||||
_auto = null;
|
||||
changed = true;
|
||||
if (wasAuto) autoPreview();
|
||||
if (wasAuto) autoPreview(preview.key);
|
||||
}
|
||||
// A followed day that turns out empty is dropped; an automatic one hands
|
||||
// over to the next ranked day.
|
||||
@@ -327,7 +332,7 @@ export function createRecentImageryLayer({
|
||||
_followKey = null;
|
||||
if (wasAuto) {
|
||||
_auto = null;
|
||||
autoPreview();
|
||||
autoPreview(followed.key);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
|
||||
@@ -1128,6 +1128,33 @@ test('an automatic overview that probes empty hands over to the next ranked day'
|
||||
assert.deepEqual(f.drapes(), { a: `${V15}|none`, b: null });
|
||||
});
|
||||
|
||||
test('with empty days shown, focus leaves an empty automatic overview with the hand-over and its successor drapes', async () => {
|
||||
const f = fixture();
|
||||
f.layer.setSources({ hls: false });
|
||||
f.layer.setShowUnavailable(true);
|
||||
await f.ready();
|
||||
assert.equal(f.diag().following, V21, 'today is followed');
|
||||
f.thumbnails.probe(V21, 'empty');
|
||||
assert.equal(f.diag().following, V15, 'yesterday takes over');
|
||||
assert.equal(f.snap().focus.key, V15, 'focus goes with it');
|
||||
f.thumbnails.probe(V15, 'present');
|
||||
assert.equal(f.snap().preview.key, V15);
|
||||
assert.equal(f.snap().preview.pending, null);
|
||||
assert.deepEqual(f.drapes(), { a: `${V15}|none`, b: null });
|
||||
});
|
||||
|
||||
test('focus on an empty automatic day moves to the next ranked day, not the nearest card, and it drapes once present', async () => {
|
||||
const f = fixture();
|
||||
await f.ready([CANDIDATES[0], CANDIDATES[1], CANDIDATES[3]]);
|
||||
assert.equal(f.snap().preview.key, S18);
|
||||
f.thumbnails.probe(S18, 'empty');
|
||||
assert.equal(f.diag().following, V21, 'the newest overview takes over');
|
||||
assert.equal(f.snap().focus.key, V21, 'not the older neighbour V15');
|
||||
f.thumbnails.probe(V21, 'present');
|
||||
assert.equal(f.snap().preview.key, V21);
|
||||
assert.deepEqual(f.drapes(), { a: `${V21}|none`, b: null });
|
||||
});
|
||||
|
||||
test('a pinned day still being probed drapes once the probe says present', async () => {
|
||||
const f = fixture();
|
||||
f.layer.setParams({ ...LINK_BOX, a: V21, mode: 0 });
|
||||
|
||||
Reference in new issue
Block a user