Skip to content

Commit

Permalink
Fixed SetWindowAction.
Browse files Browse the repository at this point in the history
Fixed reopen closed window implementation.
  • Loading branch information
imolorhe committed Nov 2, 2019
1 parent 60eb7e8 commit 0fd4b94
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<clr-icon shape="circle" class="is-solid"></clr-icon>
</span>
<span class="menu-text">
Reopen Closed Tab
{{ 'REOPEN_CLOSED_WINDOW_TEXT' | translate }}
</span>
</ng-template>
</context-menu>
5 changes: 3 additions & 2 deletions src/app/effects/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class WindowsEffects {
return { closedWindows: state.local.closedWindows, windows: state.windows, windowIds: state.windowsMeta.windowIds, action };
}),
switchMap(data => {
const lastClosedWindow = data.closedWindows.pop();
const lastClosedWindow = data.closedWindows[data.closedWindows.length - 1];
if (!lastClosedWindow || !lastClosedWindow.windowId) {
return observableEmpty();
}
Expand All @@ -73,7 +73,8 @@ export class WindowsEffects {
}

windows[lastClosedWindowId] = lastClosedWindow;
// this.store.dispatch(new windowActions.SetWindowsAction(Object.values(windows)));
this.store.dispatch(new windowActions.SetWindowsAction(Object.values(windows)));
this.windowService.setupWindow(lastClosedWindowId);
const newWindowIds = [ ...data.windowIds, lastClosedWindowId ];
return observableOf(new windowsMetaActions.SetWindowIdsAction({ ids: newWindowIds }));
}),
Expand Down
11 changes: 5 additions & 6 deletions src/app/reducers/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,15 @@ export function windows(reducer: ActionReducer<any>) {
const _windows = action.payload;

const newWindowsState = {};
_windows.forEach(window => {
_windows.forEach((window: fromRoot.PerWindowState) => {
const windowKey = window.windowId;
const windowTitle = window.title;
// const windowTitle = window.layout.title;

// Using JSON.parse and JSON.stringify instead of Object.assign for deep cloning
_windowState = JSON.parse(JSON.stringify(initWindowState));
_windowState.windowId = windowKey;
_windowState.layout.title = _windowState.layout.title || windowTitle;
// _windowState = JSON.parse(JSON.stringify(initWindowState));
// _windowState.windowId = windowKey;

newWindowsState[windowKey] = { ..._windowState };
newWindowsState[windowKey] = { ...window };
});

return newWindowsState;
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/window.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class WindowService {
/**
* Carry out any necessary house cleaning tasks.
*/
private setupWindow(windowId) {
setupWindow(windowId) {
this.store.dispatch(new queryActions.SetSubscriptionResponseListAction(windowId, { list: [] }));
this.store.dispatch(new queryActions.StopSubscriptionAction(windowId));
this.store.dispatch(new streamActions.StopStreamClientAction(windowId));
Expand Down

0 comments on commit 0fd4b94

Please sign in to comment.