Fix manual company switch route sync
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
18
ui/src/lib/company-selection.ts
Normal file
18
ui/src/lib/company-selection.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export type CompanySelectionSource = "manual" | "route_sync" | "bootstrap";
|
||||
|
||||
export function shouldSyncCompanySelectionFromRoute(params: {
|
||||
selectionSource: CompanySelectionSource;
|
||||
selectedCompanyId: string | null;
|
||||
routeCompanyId: string;
|
||||
}): boolean {
|
||||
const { selectionSource, selectedCompanyId, routeCompanyId } = params;
|
||||
|
||||
if (selectedCompanyId === routeCompanyId) return false;
|
||||
|
||||
// Let manual company switches finish their remembered-path navigation first.
|
||||
if (selectionSource === "manual" && selectedCompanyId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user