Skip to content

Commit

Permalink
Fix loading of job table state from local storage (#3072)
Browse files Browse the repository at this point in the history
Signed-off-by: Noah Held <noahheld17@gmail.com>
  • Loading branch information
zuqq committed Oct 26, 2023
1 parent bafbb8a commit f395cc7
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -120,13 +120,9 @@ const columnMatchesFromQueryStringFilters = (f: QueryStringJobFilter[]): Record<
}

const fromQueryStringSafe = (serializedPrefs: Partial<QueryStringPrefs>): Partial<JobsTablePreferences> => {
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) }),
Expand Down

0 comments on commit f395cc7

Please sign in to comment.