-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: branch관련 context를 store로 리펙토링
- Loading branch information
1 parent
055bf29
commit 74d4f51
Showing
8 changed files
with
44 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { create } from "zustand"; | ||
|
||
export type BranchListPayload = { | ||
branchList: string[]; | ||
head: string | null; | ||
}; | ||
|
||
type BranchStore = { | ||
branchList: string[]; | ||
selectedBranch: string; | ||
setBranchList: (branches: string[]) => void; | ||
setSelectedBranch: (branch: string) => void; | ||
handleChangeBranchList: (branches: BranchListPayload) => void; | ||
}; | ||
|
||
export const useBranchStore = create<BranchStore>((set) => ({ | ||
branchList: [], | ||
selectedBranch: "", | ||
setBranchList: (branches) => set({ branchList: branches }), | ||
setSelectedBranch: (branch) => set({ selectedBranch: branch }), | ||
handleChangeBranchList: (branches) => | ||
set((state) => ({ | ||
branchList: branches.branchList, | ||
selectedBranch: !state.selectedBranch && branches.head ? branches.head : state.selectedBranch, | ||
})), | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./loading"; | ||
export * from "./filteredRange"; | ||
export * from "./branch"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import type { BranchListPayload } from "store"; | ||
import type { ClusterNode } from "types"; | ||
|
||
// triggered by ide response | ||
export type IDESentEvents = { | ||
handleChangeAnalyzedData: (analyzedData: ClusterNode[]) => void; | ||
handleChangeBranchList: (branches: { branchList: string[]; head: string | null }) => void; | ||
handleChangeBranchList: (branches: BranchListPayload) => void; | ||
}; |