mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
fix(cockpit): a provider member that throws when read (a getter) leaves that provider out with one warning and keeps the rest; a worded member that starts throwing keeps its last good words; a candidate, frame or HUD view whose getter throws reads as null, so the view ends or keeps its last HUD
This commit is contained in:
1 parent
22f43aab01
commit
fbc1a9a0ec
6 files changed
+264
-92
No files matched your search
@@ -154,9 +154,9 @@ const SUBJECT_SIGNAL_TONES = Object.freeze({
|
||||
/**
|
||||
* Present a provider subject's HUD: its view model (cockpitSubjectHudView)
|
||||
* in the generic readouts, the compass at the camera's heading, the route
|
||||
* card, and its signals in Live Signals. A HUD view that is null, or a
|
||||
* `hud()` that throws, keeps the last one. Contact navigation stays with
|
||||
* aircraft, so the Contact card is withdrawn.
|
||||
* card, and its signals in Live Signals. A HUD view that is null, a `hud()`
|
||||
* that throws, or a view whose reading throws keeps the last one. Contact
|
||||
* navigation stays with aircraft, so the Contact card is withdrawn.
|
||||
*/
|
||||
function updateSubjectHud(info, nowMs, forceContext) {
|
||||
const provider = this.subjectProvider;
|
||||
@@ -176,7 +176,8 @@ function updateSubjectHud(info, nowMs, forceContext) {
|
||||
null,
|
||||
)
|
||||
: null;
|
||||
if (raw != null) this.subjectHud = cockpitSubjectHudView(raw);
|
||||
if (raw != null)
|
||||
this.subjectHud = cockpitSubjectHudView(raw) ?? this.subjectHud;
|
||||
const hud = this.subjectHud ?? cockpitSubjectHudView(null);
|
||||
const view = this.instruments;
|
||||
view.kind = 'subject';
|
||||
|
||||
@@ -604,6 +604,16 @@ test('the view ends when the frame stops coming, and gives the subject back', as
|
||||
for (const ending of [
|
||||
null,
|
||||
{ latitude: LAT, longitude: LON, id: 'other', eye: { upM: 2 } },
|
||||
// A frame whose getter throws runs provider code: as a malformed frame.
|
||||
Object.defineProperty(
|
||||
{ id: 'a1', longitude: LON, eye: { upM: 2 } },
|
||||
'latitude',
|
||||
{
|
||||
get() {
|
||||
throw new Error('latitude unavailable');
|
||||
},
|
||||
},
|
||||
),
|
||||
]) {
|
||||
const ride = subjectProvider();
|
||||
const { cockpit } = fixture(t, { providers: [ride] });
|
||||
@@ -937,6 +947,17 @@ test('a read that throws ends the view once; a hud that throws keeps the last',
|
||||
await settle();
|
||||
assert.equal(cockpit.active, true);
|
||||
assert.equal($('#cockpit-callsign').textContent, HUD.title, 'last view kept');
|
||||
// So does a view whose getter throws when read.
|
||||
ride.subject.hud = Object.defineProperty({ ...HUD }, 'title', {
|
||||
get() {
|
||||
throw new Error('title unavailable');
|
||||
},
|
||||
});
|
||||
clock.advance(200);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
assert.equal(cockpit.active, true);
|
||||
assert.equal($('#cockpit-callsign').textContent, HUD.title, 'last view kept');
|
||||
ride.subject.frame = new Error('read failed');
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
|
||||
Reference in new issue
Block a user