Fix issue where opening a new view causes the original view still to push (#2053)
* Fix issue where opening a new view causes the original view still to push * Test fix
This commit is contained in:
@@ -788,7 +788,6 @@ describe('main/windows/windowManager', () => {
|
|||||||
|
|
||||||
windowManager.handleBrowserHistoryPush(null, 'server-1_tab-messaging', '/other_type_2/subpath');
|
windowManager.handleBrowserHistoryPush(null, 'server-1_tab-messaging', '/other_type_2/subpath');
|
||||||
expect(windowManager.viewManager.openClosedTab).toBeCalledWith('server-1_other_type_2', 'http://server-1.com/other_type_2/subpath');
|
expect(windowManager.viewManager.openClosedTab).toBeCalledWith('server-1_other_type_2', 'http://server-1.com/other_type_2/subpath');
|
||||||
expect(windowManager.viewManager.showByName).toBeCalledWith('server-1_other_type_2');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open redirect view if different from current view', () => {
|
it('should open redirect view if different from current view', () => {
|
||||||
|
@@ -596,7 +596,9 @@ export class WindowManager {
|
|||||||
const cleanedPathName = currentView?.tab.server.url.pathname === '/' ? pathName : pathName.replace(currentView?.tab.server.url.pathname || '', '');
|
const cleanedPathName = currentView?.tab.server.url.pathname === '/' ? pathName : pathName.replace(currentView?.tab.server.url.pathname || '', '');
|
||||||
const redirectedViewName = urlUtils.getView(`${currentView?.tab.server.url}${cleanedPathName}`, Config.teams)?.name || viewName;
|
const redirectedViewName = urlUtils.getView(`${currentView?.tab.server.url}${cleanedPathName}`, Config.teams)?.name || viewName;
|
||||||
if (this.viewManager?.closedViews.has(redirectedViewName)) {
|
if (this.viewManager?.closedViews.has(redirectedViewName)) {
|
||||||
|
// If it's a closed view, just open it and stop
|
||||||
this.viewManager.openClosedTab(redirectedViewName, `${currentView?.tab.server.url}${cleanedPathName}`);
|
this.viewManager.openClosedTab(redirectedViewName, `${currentView?.tab.server.url}${cleanedPathName}`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
let redirectedView = this.viewManager?.views.get(redirectedViewName) || currentView;
|
let redirectedView = this.viewManager?.views.get(redirectedViewName) || currentView;
|
||||||
if (redirectedView !== currentView && redirectedView?.tab.server.name === this.currentServerName && redirectedView?.isLoggedIn) {
|
if (redirectedView !== currentView && redirectedView?.tab.server.name === this.currentServerName && redirectedView?.isLoggedIn) {
|
||||||
|
Reference in New Issue
Block a user