Skip to content

Commit

Permalink
🐛 Fix handling side bar when mouse click activity
Browse files Browse the repository at this point in the history
Closes #7
  • Loading branch information
Andrei Orlov committed Jul 2, 2022
1 parent 5c6ae0b commit 2afedf6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/modules/activity-bar/register-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@ import { OrdoEventHandler } from "@core/types";
import { OrdoEvents } from "@init/types";
import { ActivityBarEvents } from "@modules/activity-bar/types";

const handleSelect: OrdoEventHandler<"@activity-bar/select"> = ({ draft, payload }) => {
const handleSelect: OrdoEventHandler<"@activity-bar/select"> = ({ draft, payload, transmission }) => {
if (payload === "Editor") {
transmission.emit("@side-bar/show", null);
} else {
transmission.emit("@side-bar/hide", null);
}

draft.activityBar.current = payload;
};

const handleOpen =
<T extends keyof OrdoEvents>(activity: string, showSidebar = false): OrdoEventHandler<T> =>
<T extends keyof OrdoEvents>(activity: string): OrdoEventHandler<T> =>
({ transmission }) => {
transmission.emit(showSidebar ? "@side-bar/show" : "@side-bar/hide", null);
transmission.emit("@activity-bar/select", activity);
};

const handleOpenEditor = handleOpen<"@activity-bar/open-editor">("Editor", true);
const handleOpenEditor = handleOpen<"@activity-bar/open-editor">("Editor");
const handleOpenGraph = handleOpen<"@activity-bar/open-graph">("Graph");
const handleOpenSettings = handleOpen<"@activity-bar/open-settings">("Settings");
const handleOpenCheckboxes = handleOpen<"@activity-bar/open-checkboxes">("Checkboxes");
Expand Down

0 comments on commit 2afedf6

Please sign in to comment.