Lib: Don't cache driver dropdown options

This commit is contained in:
2025-02-04 21:55:46 +01:00
parent 31749f6e0f
commit d6ea629d32

View File

@ -32,27 +32,20 @@ export const team_dropdown_options = (teams: Team[]): DropdownOption[] => {
return team_dropdown_opts; return team_dropdown_opts;
}; };
let driver_dropdown_opts: DropdownOption[] | null = null;
/** /**
* Generates a list of [DropdownOptions] for a <Dropdown> component. * Generates a list of [DropdownOptions] for a <Dropdown> component.
* Cached until page reload. * Not cached, because drivers are often filtered by active/inactive.
*/ */
export const driver_dropdown_options = (drivers: Driver[]): DropdownOption[] => { export const driver_dropdown_options = (drivers: Driver[]): DropdownOption[] => {
if (!driver_dropdown_opts) { return drivers.map((driver: Driver) => {
console.log("driver_dropdown_options"); return {
driver_dropdown_opts = drivers.map((driver: Driver) => { label: driver.code,
return { value: driver.id,
label: driver.code, icon_url: driver.headshot_url,
value: driver.id, icon_width: DRIVER_HEADSHOT_WIDTH,
icon_url: driver.headshot_url, icon_height: DRIVER_HEADSHOT_HEIGHT,
icon_width: DRIVER_HEADSHOT_WIDTH, };
icon_height: DRIVER_HEADSHOT_HEIGHT, });
};
});
}
return driver_dropdown_opts;
}; };
let race_dropdown_opts: DropdownOption[] | null = null; let race_dropdown_opts: DropdownOption[] | null = null;