From f395cc7adbfaf0fb8b7174f57d6b48a3fc365353 Mon Sep 17 00:00:00 2001 From: Noah Held <41909795+zuqq@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:47:40 +0100 Subject: [PATCH] Fix loading of job table state from local storage (#3072) Signed-off-by: Noah Held --- .../services/lookoutV2/JobsTablePreferencesService.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/internal/lookout/ui/src/services/lookoutV2/JobsTablePreferencesService.ts b/internal/lookout/ui/src/services/lookoutV2/JobsTablePreferencesService.ts index b69924d338f..b01c3a91651 100644 --- a/internal/lookout/ui/src/services/lookoutV2/JobsTablePreferencesService.ts +++ b/internal/lookout/ui/src/services/lookoutV2/JobsTablePreferencesService.ts @@ -62,7 +62,7 @@ type QueryStringJobFilter = { // Keys are shortened to keep URL size lower export interface QueryStringPrefs { // Grouped columns - g: string[] | [null] + g: string[] // Expanded rows e: string[] // Current page number @@ -120,13 +120,9 @@ const columnMatchesFromQueryStringFilters = (f: QueryStringJobFilter[]): Record< } const fromQueryStringSafe = (serializedPrefs: Partial): Partial => { - const { e, page, ps, sort, f, sb } = serializedPrefs - let g = serializedPrefs.g - if (!(Array.isArray(g) && g.length > 0 && g.map((elem) => typeof elem === "string").reduce((a, b) => a && b, true))) { - g = [] - } + const { g, e, page, ps, sort, f, sb } = serializedPrefs return { - ...(g && { groupedColumns: g as ColumnId[] }), + ...(g && Array.isArray(g) && g.every((a) => typeof a === "string") && { groupedColumns: g as ColumnId[] }), ...(e && { expandedState: Object.fromEntries(e.map((rowId) => [rowId, true])) }), ...(page !== undefined && { pageIndex: Number(page) }), ...(ps !== undefined && { pageSize: Number(ps) }),