Skip to content

Commit a5a23a6

Browse files
committed
Add comments
1 parent 0c6066b commit a5a23a6

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

packages/transition-frontend/src/components/forms/schedules/TransitScheduleButton.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,18 @@ const TransitScheduleButton: React.FunctionComponent<ScheduleButtonProps> = (pro
5858
const serviceId = props.schedule.attributes.service_id;
5959
const periodsGroups = Preferences.get('transit.periods');
6060
const periodsGroupShortname = props.schedule.attributes.periods_group_shortname;
61-
// Add defensive check before accessing the template
61+
// Add defensive check before accessing the template, otherwise the interface breaks
6262
let periodsGroupName = '-';
6363
if (periodsGroupShortname) {
64-
// Check if the template exists
6564
if (periodsGroups[periodsGroupShortname]) {
6665
periodsGroupName = periodsGroups[periodsGroupShortname].name[props.i18n.language];
6766
} else {
68-
// The template doesn't exist anymore, set it to default
6967
props.schedule.set('periods_group_shortname', 'default');
70-
71-
// If we can save right away, do so (optional)
72-
// Try to save the change silently
7368
try {
7469
props.schedule.save(serviceLocator.socketEventManager);
7570
} catch (e) {
7671
console.warn('Could not save schedule with updated template', e);
7772
}
78-
79-
// Use default template name if it exists
8073
if (periodsGroups['default'] && periodsGroups['default'].name) {
8174
periodsGroupName = periodsGroups['default'].name[props.i18n.language];
8275
}

0 commit comments

Comments
 (0)