Skip to content

Commit

Permalink
Guard against null gamespaceoff in event timeline.
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-bstein committed Jan 24, 2024
1 parent c298a31 commit 1eb2e17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions projects/gameboard-ui/src/app/api/event-horizon.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class EventHorizonService {
const timestamp = this.apiDateTimeService.toDateTime(event.timestamp as any);
if (!timestamp)
throw new Error(`Couldn't parse datetime for timeline event: ${JSON.stringify(event.timestamp)}`);

event.timestamp = timestamp;

// if this is a gamespace event, its eventData has another propert that needs help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { Injectable } from '@angular/core';
import { DateTime } from 'luxon';
import { MarkdownHelpersService } from './markdown-helpers.service';
import { DataGroup } from 'vis-timeline';
import { NowService } from './now.service';

@Injectable({ providedIn: 'root' })
export class EventHorizonRenderingService {
constructor(private markdownHelpers: MarkdownHelpersService) { }
constructor(
private markdownHelpers: MarkdownHelpersService,
private nowService: NowService) { }

public getViewOptions(eventHorizonVm: TeamEventHorizonViewModel): EventHorizonViewOptions {
const sessionEnd = eventHorizonVm.team.session.end || DateTime.now();
Expand Down Expand Up @@ -111,7 +114,7 @@ export class EventHorizonRenderingService {
const typedEvent = timelineEvent as unknown as EventHorizonGamespaceOnOffEvent;
const baseItem = this.toGenericDataItem(timelineEvent, challengeSpec, "Gamespace On", "eh-event-type-gamespace-on-off", false);

baseItem.end = typedEvent.eventData.offAt.toJSDate();
baseItem.end = typedEvent.eventData?.offAt?.toJSDate() || this.nowService.now();
baseItem.eventData = typedEvent;
baseItem.type = "background";

Expand Down

0 comments on commit 1eb2e17

Please sign in to comment.