(editFunction: (queryObject: Record<string, string | null | undefined>) => void)
| 80 | * }); |
| 81 | */ |
| 82 | export function editQuery(editFunction: (queryObject: Record<string, string | null | undefined>) => void) { |
| 83 | try { |
| 84 | const location = appGlobal.historyLocation(); |
| 85 | if (!location) { |
| 86 | // biome-ignore lint/suspicious/noConsole: intentional console usage |
| 87 | console.warn('Location not available yet, skipping query update'); |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | // TanStack Router uses searchStr for the raw search string |
| 92 | const searchStr = location.searchStr ?? ''; |
| 93 | const currentObj = queryToObj(searchStr); |
| 94 | editFunction(currentObj); |
| 95 | |
| 96 | const newQuery = objToQuery(currentObj); |
| 97 | |
| 98 | if (searchStr !== newQuery) { |
| 99 | const path = location.pathname; |
| 100 | appGlobal.historyReplace(`${path}${newQuery}`); |
| 101 | } |
| 102 | } catch (error) { |
| 103 | // biome-ignore lint/suspicious/noConsole: intentional console usage |
| 104 | console.warn('Failed to update query:', error); |
| 105 | } |
| 106 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…