From 99c53c1df306670583fc4af042d11739dbfd9101 Mon Sep 17 00:00:00 2001 From: Atul Bhatt <38177419+atulbhatt-system32@users.noreply.github.com> Date: Tue, 26 Dec 2023 17:52:41 +0530 Subject: [PATCH] fix: file switch doesn't work when the file content is completely the same --- .../workspaceTreeView/WorkspaceTreeView.tsx | 22 ------------------- src/pages/main/hooks/useHandlers.ts | 4 ++++ src/pages/main/hooks/usePanels.ts | 3 +++ .../main/processor/hooks/useFileTreeEvent.ts | 3 +++ .../main/processor/hooks/useNodeTreeEvent.ts | 2 +- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/components/main/actionsPanel/workspaceTreeView/WorkspaceTreeView.tsx b/src/components/main/actionsPanel/workspaceTreeView/WorkspaceTreeView.tsx index 8aedc18b..7f7faca2 100644 --- a/src/components/main/actionsPanel/workspaceTreeView/WorkspaceTreeView.tsx +++ b/src/components/main/actionsPanel/workspaceTreeView/WorkspaceTreeView.tsx @@ -35,42 +35,20 @@ const AutoExpandDelayOnDnD = 1 * 1000; export default function WorkspaceTreeView() { const dispatch = useDispatch(); const { - osType, - theme, - - workspace, - project, initialFileUidToOpen, currentFileUid, fileTree, - fFocusedItem: focusedItem, fExpandedItems: expandedItems, - fExpandedItemsObj: expandedItemsObj, fSelectedItems: selectedItems, - fSelectedItemsObj: selectedItemsObj, - hoveredFileUid, - - lastFileAction, - - fileAction, linkToOpen, - navigatorDropdownType, - - activePanel, - - didUndo, - didRedo, - currentCommand, } = useAppState(); const { addRunningActions, removeRunningActions, filesReferenceData, invalidFileNodes, - addInvalidFileNodes, - removeInvalidFileNodes, } = useContext(MainContext); const { focusedItemRef, fileTreeViewData } = useSync(); diff --git a/src/pages/main/hooks/useHandlers.ts b/src/pages/main/hooks/useHandlers.ts index ffdf30a8..eb5d1b92 100644 --- a/src/pages/main/hooks/useHandlers.ts +++ b/src/pages/main/hooks/useHandlers.ts @@ -103,6 +103,7 @@ export const useHandlers = ({ }, [recentProjectContexts, recentProjectNames, recentProjectHandlers], ); + const importProject = useCallback( async ( fsType: TProjectContext, @@ -189,12 +190,15 @@ export const useHandlers = ({ // current project - reload trigger const [reloadCurrentProjectTrigger, setReloadCurrentProjectTrigger] = useState(false); + const triggerCurrentProjectReload = useCallback(() => { setReloadCurrentProjectTrigger((prev) => !prev); }, []); + useEffect(() => { reloadCurrentProject(); }, [reloadCurrentProjectTrigger]); + const reloadCurrentProject = useCallback(async () => { if (project.context === "local") { const { diff --git a/src/pages/main/hooks/usePanels.ts b/src/pages/main/hooks/usePanels.ts index bb611e09..264054c6 100644 --- a/src/pages/main/hooks/usePanels.ts +++ b/src/pages/main/hooks/usePanels.ts @@ -11,6 +11,7 @@ export const usePanels = () => { const [codeViewOffsetLeft, setCodeViewOffsetLeft] = useState(12); const [codeViewHeight, setCodeViewHeight] = useState("40"); const [codeViewDragging, setCodeViewDragging] = useState(false); + const dragCodeView = useCallback((e: React.DragEvent) => { e.preventDefault(); setCodeViewOffsetTop( @@ -23,6 +24,7 @@ export const usePanels = () => { setCodeViewDragging(true); } }, []); + const dragEndCodeView = useCallback((e: React.DragEvent) => { e.preventDefault(); const offsetTop = ( @@ -34,6 +36,7 @@ export const usePanels = () => { setCodeViewDragging(false); localStorage.setItem("offsetTop", offsetTop); }, []); + const dropCodeView = useCallback((e: React.DragEvent) => { e.preventDefault(); }, []); diff --git a/src/pages/main/processor/hooks/useFileTreeEvent.ts b/src/pages/main/processor/hooks/useFileTreeEvent.ts index 2cc592e1..e3e47c9d 100644 --- a/src/pages/main/processor/hooks/useFileTreeEvent.ts +++ b/src/pages/main/processor/hooks/useFileTreeEvent.ts @@ -42,6 +42,7 @@ export const useFileTreeEvent = () => { const clearFutureHistoryTriggerRef = useRef(false); const lastFileActionRef = useRef({ action: null }); + useEffect(() => { if (clearFutureHistoryTriggerRef.current) { // remove invalid history events after `remove` action @@ -66,6 +67,7 @@ export const useFileTreeEvent = () => { } } }, [fileAction]); + useEffect(() => { if (didUndo) { const { action, payload } = lastFileAction; @@ -195,6 +197,7 @@ export const useFileTreeEvent = () => { fileHandlers, ], ); + const _move = useCallback( async ({ uids, diff --git a/src/pages/main/processor/hooks/useNodeTreeEvent.ts b/src/pages/main/processor/hooks/useNodeTreeEvent.ts index 57605708..5ac0daa8 100644 --- a/src/pages/main/processor/hooks/useNodeTreeEvent.ts +++ b/src/pages/main/processor/hooks/useNodeTreeEvent.ts @@ -303,7 +303,7 @@ export const useNodeTreeEvent = () => { } removeRunningActions(["processor-update"]); - }, [currentFileContent]); + }, [currentFileUid]); // expand nodes that need to be expanded when it's just select-event useEffect(() => {