Fix saving last cluster while jumping from tray

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev committed 2020-11-19 11:31:36 +03:00
1 parent cb13079077
commit 07f44f9454
5 files changed
+7 -6

No files matched your search

+4 -2
View File
@@ -1,4 +1,4 @@
import type { WorkspaceId } from "./workspace-store";
import { WorkspaceId, workspaceStore } from "./workspace-store";
import path from "path";
import { app, ipcRenderer, remote, webFrame } from "electron";
import { unlink } from "fs-extra";
@@ -138,7 +138,9 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
@action
setActive(id: ClusterId) {
this.activeCluster = this.clusters.has(id) ? id : null;
const clusterId = this.clusters.has(id) ? id : null;
this.activeCluster = clusterId;
workspaceStore.setLastActiveClusterId(clusterId);
}
@action
+3 -1
View File
@@ -72,7 +72,8 @@ export class Workspace implements WorkspaceModel, WorkspaceState {
id: this.id,
name: this.name,
description: this.description,
ownerRef: this.ownerRef
ownerRef: this.ownerRef,
lastActiveClusterId: this.lastActiveClusterId
})
}
}
@@ -191,6 +192,7 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
@action
setLastActiveClusterId(clusterId: ClusterId, workspaceId = this.currentWorkspaceId) {
console.log("Passed cluster ID", clusterId, "current workspace id = ", workspaceId)
if (clusterId != null) {
this.getById(workspaceId).lastActiveClusterId = clusterId;
}
-1
View File
@@ -94,7 +94,6 @@ export function createTrayMenu(windowManager: WindowManager): Menu {
toolTip: clusterId,
async click() {
workspaceStore.setActive(workspace);
clusterStore.setActive(clusterId);
windowManager.navigate(clusterViewURL({ params: { clusterId } }));
}
}
@@ -167,7 +167,6 @@ export class AddCluster extends React.Component {
if (newClusters.length === 1) {
const clusterId = newClusters[0].id;
clusterStore.setActive(clusterId);
workspaceStore.setLastActiveClusterId(clusterId);
navigate(clusterViewURL({ params: { clusterId } }));
} else {
if (newClusters.length > 1) {
@@ -31,7 +31,6 @@ interface Props {
@observer
export class ClustersMenu extends React.Component<Props> {
showCluster = (clusterId: ClusterId) => {
workspaceStore.setLastActiveClusterId(clusterId);
navigate(clusterViewURL({ params: { clusterId } }));
}