mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
refactor(stores): split dockview store into problem-specific store
- Remove generic dockview store (`src/stores/dockview.tsx`) - Add problem-specific dockview store (`src/stores/problem-dockview.tsx`) - Remove submission-related state as it's no longer needed
This commit is contained in:
parent
3042af4575
commit
c182452dd0
@ -1,34 +0,0 @@
|
|||||||
import { create } from "zustand";
|
|
||||||
import type { DockviewApi } from "dockview";
|
|
||||||
import { createJSONStorage, persist } from "zustand/middleware";
|
|
||||||
import type { SubmissionWithTestcaseResult } from "@/types/prisma";
|
|
||||||
|
|
||||||
export type DockviewState = {
|
|
||||||
api: DockviewApi | null;
|
|
||||||
submission: SubmissionWithTestcaseResult | null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type DockviewActions = {
|
|
||||||
setApi: (api: DockviewApi) => void;
|
|
||||||
setSubmission: (submission: SubmissionWithTestcaseResult) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type DockviewStore = DockviewState & DockviewActions;
|
|
||||||
|
|
||||||
export const useDockviewStore = create<DockviewStore>()(
|
|
||||||
persist(
|
|
||||||
(set) => ({
|
|
||||||
api: null,
|
|
||||||
submission: null,
|
|
||||||
setApi: (api) => set({ api }),
|
|
||||||
setSubmission: (submission) => set({ submission }),
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
name: "zustand:dockview",
|
|
||||||
storage: createJSONStorage(() => localStorage),
|
|
||||||
partialize: (state) => ({
|
|
||||||
submission: state.submission,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
20
src/stores/problem-dockview.ts
Normal file
20
src/stores/problem-dockview.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { create } from "zustand";
|
||||||
|
import type { DockviewApi } from "dockview";
|
||||||
|
|
||||||
|
export type ProblemDockviewState = {
|
||||||
|
api: DockviewApi | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ProblemDockviewActions = {
|
||||||
|
setApi: (api: DockviewApi) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ProblemDockviewStore = ProblemDockviewState &
|
||||||
|
ProblemDockviewActions;
|
||||||
|
|
||||||
|
export const useProblemDockviewStore = create<ProblemDockviewStore>()(
|
||||||
|
(set) => ({
|
||||||
|
api: null,
|
||||||
|
setApi: (api) => set({ api }),
|
||||||
|
})
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user