Skip to content

Commit

Permalink
fix: file switch doesn't work when the file content is completely the…
Browse files Browse the repository at this point in the history
… same
  • Loading branch information
atulbhatt-system32 committed Dec 26, 2023
1 parent 3a108ea commit 99c53c1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/pages/main/hooks/useHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const useHandlers = ({
},
[recentProjectContexts, recentProjectNames, recentProjectHandlers],
);

const importProject = useCallback(
async (
fsType: TProjectContext,
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions src/pages/main/hooks/usePanels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement>) => {
e.preventDefault();
setCodeViewOffsetTop(
Expand All @@ -23,6 +24,7 @@ export const usePanels = () => {
setCodeViewDragging(true);
}
}, []);

const dragEndCodeView = useCallback((e: React.DragEvent<HTMLDivElement>) => {
e.preventDefault();
const offsetTop = (
Expand All @@ -34,6 +36,7 @@ export const usePanels = () => {
setCodeViewDragging(false);
localStorage.setItem("offsetTop", offsetTop);
}, []);

const dropCodeView = useCallback((e: React.DragEvent<HTMLDivElement>) => {
e.preventDefault();
}, []);
Expand Down
3 changes: 3 additions & 0 deletions src/pages/main/processor/hooks/useFileTreeEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const useFileTreeEvent = () => {

const clearFutureHistoryTriggerRef = useRef(false);
const lastFileActionRef = useRef<TFileAction>({ action: null });

useEffect(() => {
if (clearFutureHistoryTriggerRef.current) {
// remove invalid history events after `remove` action
Expand All @@ -66,6 +67,7 @@ export const useFileTreeEvent = () => {
}
}
}, [fileAction]);

useEffect(() => {
if (didUndo) {
const { action, payload } = lastFileAction;
Expand Down Expand Up @@ -195,6 +197,7 @@ export const useFileTreeEvent = () => {
fileHandlers,
],
);

const _move = useCallback(
async ({
uids,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/main/processor/hooks/useNodeTreeEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 99c53c1

Please sign in to comment.