mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Stop roster hover and focus from moving the camera while Space Missions goes off
While Space Missions was going off (its Satellites restore still running, the panel still shown), hovering or keyboard-focusing a roster row still scheduled the roster preview, which flew the camera to that launch with nothing left to end it. The preview is no longer scheduled once the layer is going off, and one already pending is dropped. Selection, focus, replay and stepping from the Data Layers row were already refused then. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
9ac937af82
commit
8675ead171
3 files changed
+35
-3
No files matched your search
@@ -380,14 +380,20 @@ export function createPanel({ state: layerState, services, parts, source }) {
|
||||
|
||||
function scheduleMissionRosterPreview(index) {
|
||||
const launch = layerState._launches[index];
|
||||
if (!launch || layerState._selectedLaunchId) return;
|
||||
// Once the layer is going off (its Satellites restore may still be
|
||||
// running) hovering or focusing a roster row moves no camera.
|
||||
if (!launch || layerState._selectedLaunchId || !layerState._enabled) return;
|
||||
if (layerState._missionRosterHoverTimer)
|
||||
clearTimeout(layerState._missionRosterHoverTimer);
|
||||
layerState._hoveredRosterLaunchId = launch.id;
|
||||
parts.overlays.syncMissionOverlayEntries();
|
||||
layerState._missionRosterHoverTimer = setTimeout(() => {
|
||||
layerState._missionRosterHoverTimer = null;
|
||||
if (layerState._hoveredRosterLaunchId !== launch.id) return;
|
||||
if (
|
||||
layerState._hoveredRosterLaunchId !== launch.id ||
|
||||
!layerState._enabled
|
||||
)
|
||||
return;
|
||||
const currentLaunch = resolveMissionRosterPreviewLaunch(
|
||||
layerState._launches,
|
||||
launch.id,
|
||||
|
||||
@@ -9,6 +9,7 @@ function fixture() {
|
||||
const state = createState({
|
||||
services: { overlays: {}, render: {} },
|
||||
});
|
||||
state._enabled = true;
|
||||
const calls = [];
|
||||
const parts = {
|
||||
overlays: {
|
||||
@@ -194,3 +195,26 @@ test('the panel commands act on the selected mission', () => {
|
||||
['select', null, undefined],
|
||||
]);
|
||||
});
|
||||
|
||||
test('a roster row hovered or focused while the layer goes off moves no camera', async () => {
|
||||
const { state, panel, calls } = fixture();
|
||||
state._launches = [launch('a'), launch('b')];
|
||||
panel.createMissionPanel();
|
||||
panel.renderMissionRoster();
|
||||
|
||||
// Hovered just before the layer goes off: the pending preview is dropped.
|
||||
panel.commands.rosterPointerEnter(0);
|
||||
state._enabled = false;
|
||||
await new Promise((resolve) => setTimeout(resolve, 160));
|
||||
|
||||
// Hovered or focused after it went off, while the panel still shows.
|
||||
panel.commands.rosterPointerEnter(1);
|
||||
panel.commands.rosterFocus(1);
|
||||
assert.equal(state._missionRosterHoverTimer, null, 'no preview is pending');
|
||||
await new Promise((resolve) => setTimeout(resolve, 160));
|
||||
assert.deepEqual(
|
||||
calls.filter(([name]) => name === 'preview'),
|
||||
[],
|
||||
);
|
||||
panel.clearMissionPanel();
|
||||
});
|
||||
Reference in new issue
Block a user