fix issue where app redirects to home after initialization but user has already started a chat (#4260)
This commit is contained in:
@@ -15,6 +15,7 @@ Object.defineProperty(window, 'location', {
|
|||||||
search: '',
|
search: '',
|
||||||
href: 'http://localhost:3000',
|
href: 'http://localhost:3000',
|
||||||
origin: 'http://localhost:3000',
|
origin: 'http://localhost:3000',
|
||||||
|
pathname: '/',
|
||||||
},
|
},
|
||||||
writable: true,
|
writable: true,
|
||||||
});
|
});
|
||||||
@@ -196,6 +197,7 @@ describe('App Component - Brand New State', () => {
|
|||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
window.location.hash = '';
|
window.location.hash = '';
|
||||||
window.location.search = '';
|
window.location.search = '';
|
||||||
|
window.location.pathname = '/';
|
||||||
window.sessionStorage.clear();
|
window.sessionStorage.clear();
|
||||||
window.localStorage.clear();
|
window.localStorage.clear();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -95,8 +95,18 @@ export const initializeApp = async ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.location.hash = '#/';
|
|
||||||
window.history.replaceState({}, '', '#/');
|
// Only redirect to home if we're still on the initial empty hash or root
|
||||||
|
// This prevents redirecting users who have already navigated elsewhere during initialization
|
||||||
|
const currentHash = window.location.hash;
|
||||||
|
const currentPathname = window.location.pathname;
|
||||||
|
const isOnRootRoute =
|
||||||
|
currentPathname === '/' && (!currentHash || currentHash === '#' || currentHash === '#/');
|
||||||
|
|
||||||
|
if (isOnRootRoute) {
|
||||||
|
window.location.hash = '#/';
|
||||||
|
window.history.replaceState({}, '', '#/');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const initializeForSessionResume = async ({
|
const initializeForSessionResume = async ({
|
||||||
|
|||||||
Reference in New Issue
Block a user