Skip to content

Commit

Permalink
enketoHelper: fix error if timestamps are null
Browse files Browse the repository at this point in the history
if the survey doesn't use start and end times, timestamps will be null. This is fine and we can use optional chaining to prevent throwing an error here
  • Loading branch information
JGreenlee committed Nov 21, 2023
1 parent 01f8d2a commit 828ee12
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions www/js/survey/enketo/enketoHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ export function saveResponse(surveyName: string, enketoForm: Form, appConfig, op
return new Error(i18next.t('survey.enketo-timestamps-invalid')); //"Timestamps are invalid. Please ensure that the start time is before the end time.");
}
// if timestamps were not resolved from the survey, we will use the trip or place timestamps
data.start_ts = timestamps.start_ts || opts.timelineEntry.enter_ts;
data.end_ts = timestamps.end_ts || opts.timelineEntry.exit_ts;
data.start_ts = timestamps?.start_ts || opts.timelineEntry.enter_ts;
data.end_ts = timestamps?.end_ts || opts.timelineEntry.exit_ts;
// UUID generated using this method https://stackoverflow.com/a/66332305
data.match_id = URL.createObjectURL(new Blob([])).slice(-36);
} else {
Expand Down

0 comments on commit 828ee12

Please sign in to comment.