From d6ea629d32895400c7cea3edd28a0165df60600e Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Tue, 4 Feb 2025 21:55:46 +0100 Subject: [PATCH] Lib: Don't cache driver dropdown options --- src/lib/dropdown.ts | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/lib/dropdown.ts b/src/lib/dropdown.ts index a0dbf0b..3a5fac6 100644 --- a/src/lib/dropdown.ts +++ b/src/lib/dropdown.ts @@ -32,27 +32,20 @@ export const team_dropdown_options = (teams: Team[]): DropdownOption[] => { return team_dropdown_opts; }; -let driver_dropdown_opts: DropdownOption[] | null = null; - /** * Generates a list of [DropdownOptions] for a component. - * Cached until page reload. + * Not cached, because drivers are often filtered by active/inactive. */ export const driver_dropdown_options = (drivers: Driver[]): DropdownOption[] => { - if (!driver_dropdown_opts) { - console.log("driver_dropdown_options"); - driver_dropdown_opts = drivers.map((driver: Driver) => { - return { - label: driver.code, - value: driver.id, - icon_url: driver.headshot_url, - icon_width: DRIVER_HEADSHOT_WIDTH, - icon_height: DRIVER_HEADSHOT_HEIGHT, - }; - }); - } - - return driver_dropdown_opts; + return drivers.map((driver: Driver) => { + return { + label: driver.code, + value: driver.id, + icon_url: driver.headshot_url, + icon_width: DRIVER_HEADSHOT_WIDTH, + icon_height: DRIVER_HEADSHOT_HEIGHT, + }; + }); }; let race_dropdown_opts: DropdownOption[] | null = null;