Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cannot redirect to last visited location on relaunch #6949

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions packages/insomnia/src/ui/routes/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,18 @@ export const indexLoader: LoaderFunction = async () => {
}
}

if (personalOrganization) {
return redirect(`/organization/${personalOrganization.id}`);
}

if (organizations.length > 0) {
return redirect(`/organization/${organizations[0].id}`);
const organizationId = personalOrganization?.id || organizations?.[0]?.id;
if (organizationId) {
const prevOrganizationLocation = localStorage.getItem(
`locationHistoryEntry:${organizationId}`
);
if (prevOrganizationLocation) {
console.log('Redirecting to last visited location', prevOrganizationLocation);
// Don't check if the resources referenced in location exist, such as project, workspace, etc.
// Leave that to the respective loaders, show more friendly notices and be able to fallback to home page.
return redirect(prevOrganizationLocation);
}
return redirect(`/organization/${organizationId}`);
}
} catch (error) {
console.log('Failed to load Organizations', error);
Expand Down
Loading