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:
Devin Binnie
2022-04-19 10:29:19 -04:00
committed by GitHub
parent 1c44c8527a
commit b240d446d8
2 changed files with 2 additions and 1 deletions

View File

@@ -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', () => {

View File

@@ -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) {