perf: optimize Tasker boot and kanban load
This commit is contained in:
@@ -75,7 +75,12 @@ const buildIssueStreamUrl = (workspaceSlug: string, projectId: string) => {
|
||||
return url.toString();
|
||||
};
|
||||
|
||||
export const useIssueRealtimeEvents = (storeType: EIssuesStoreType, workspaceSlug?: string, projectId?: string) => {
|
||||
export const useIssueRealtimeEvents = (
|
||||
storeType: EIssuesStoreType,
|
||||
workspaceSlug?: string,
|
||||
projectId?: string,
|
||||
enabled = true
|
||||
) => {
|
||||
const { issueMap, issues, issuesFilter } = useIssues(storeType);
|
||||
const issueServiceRef = useRef(new IssueService());
|
||||
const issueMapRef = useRef(issueMap);
|
||||
@@ -98,7 +103,8 @@ export const useIssueRealtimeEvents = (storeType: EIssuesStoreType, workspaceSlu
|
||||
}, [issuesFilter]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!workspaceSlug || !projectId || !REALTIME_STORE_TYPES.has(storeType) || typeof window === "undefined") return;
|
||||
if (!enabled || !workspaceSlug || !projectId || !REALTIME_STORE_TYPES.has(storeType) || typeof window === "undefined")
|
||||
return;
|
||||
|
||||
let socket: WebSocket | undefined;
|
||||
let reconnectTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
@@ -280,5 +286,5 @@ export const useIssueRealtimeEvents = (storeType: EIssuesStoreType, workspaceSlu
|
||||
if (reconnectTimer) clearTimeout(reconnectTimer);
|
||||
socket?.close();
|
||||
};
|
||||
}, [storeType, workspaceSlug, projectId]);
|
||||
}, [enabled, storeType, workspaceSlug, projectId]);
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ import { useTimeLineType } from "../components/gantt-chart/contexts";
|
||||
export const useTimeLineChart = (timelineType: TTimelineType): IBaseTimelineStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (!context) throw new Error("useTimeLineChart must be used within StoreProvider");
|
||||
if (!context.timelineStore) throw context.loadTimelineStore();
|
||||
|
||||
return getTimelineStore(context.timelineStore, timelineType);
|
||||
};
|
||||
@@ -27,6 +28,7 @@ export const useTimeLineChartStore = (): IBaseTimelineStore => {
|
||||
|
||||
if (!context) throw new Error("useTimeLineChartStore must be used within StoreProvider");
|
||||
if (!timelineType) throw new Error("useTimeLineChartStore must be used within TimeLineTypeContext");
|
||||
if (!context.timelineStore) throw context.loadTimelineStore();
|
||||
|
||||
return getTimelineStore(context.timelineStore, timelineType);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user