Fix Infinite loop on invite route (#2866)
This commit is contained in:
@ -47,7 +47,9 @@ export const PageChangeEffect = () => {
|
|||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}, [location, previousLocation]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
const isMachinOngoingUserCreationRoute =
|
const isMachinOngoingUserCreationRoute =
|
||||||
isMatchingLocation(AppPath.SignUp) ||
|
isMatchingLocation(AppPath.SignUp) ||
|
||||||
isMatchingLocation(AppPath.SignIn) ||
|
isMatchingLocation(AppPath.SignIn) ||
|
||||||
@ -108,7 +110,16 @@ export const PageChangeEffect = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}, [
|
||||||
|
enqueueSnackBar,
|
||||||
|
isMatchingLocation,
|
||||||
|
location.pathname,
|
||||||
|
navigate,
|
||||||
|
onboardingStatus,
|
||||||
|
workspaceFromInviteHashQuery,
|
||||||
|
]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case isMatchingLocation(AppPath.RecordTablePage): {
|
case isMatchingLocation(AppPath.RecordTablePage): {
|
||||||
setHotkeyScope(TableHotkeyScope.Table, {
|
setHotkeyScope(TableHotkeyScope.Table, {
|
||||||
@ -177,7 +188,9 @@ export const PageChangeEffect = () => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, [isMatchingLocation, setHotkeyScope]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
setToIntitialCommandMenu();
|
setToIntitialCommandMenu();
|
||||||
|
|
||||||
addToCommandMenu([
|
addToCommandMenu([
|
||||||
@ -190,7 +203,9 @@ export const PageChangeEffect = () => {
|
|||||||
onCommandClick: () => openCreateActivity({ type: 'Task' }),
|
onCommandClick: () => openCreateActivity({ type: 'Task' }),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
}, [addToCommandMenu, setToIntitialCommandMenu, openCreateActivity]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
eventTracker('pageview', {
|
eventTracker('pageview', {
|
||||||
location: {
|
location: {
|
||||||
@ -198,20 +213,7 @@ export const PageChangeEffect = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}, 500);
|
}, 500);
|
||||||
}, [
|
}, [eventTracker, location.pathname]);
|
||||||
onboardingStatus,
|
|
||||||
navigate,
|
|
||||||
isMatchingLocation,
|
|
||||||
setHotkeyScope,
|
|
||||||
location,
|
|
||||||
previousLocation,
|
|
||||||
eventTracker,
|
|
||||||
workspaceFromInviteHashQuery,
|
|
||||||
enqueueSnackBar,
|
|
||||||
addToCommandMenu,
|
|
||||||
openCreateActivity,
|
|
||||||
setToIntitialCommandMenu,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return <></>;
|
return <></>;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { useCallback } from 'react';
|
||||||
import { matchPath, useLocation } from 'react-router-dom';
|
import { matchPath, useLocation } from 'react-router-dom';
|
||||||
import { parse } from 'url';
|
import { parse } from 'url';
|
||||||
|
|
||||||
@ -6,11 +7,14 @@ import { AppBasePath } from '@/types/AppBasePath';
|
|||||||
export const useIsMatchingLocation = () => {
|
export const useIsMatchingLocation = () => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
return (path: string, basePath?: AppBasePath) => {
|
return useCallback(
|
||||||
|
(path: string, basePath?: AppBasePath) => {
|
||||||
const constructedPath = basePath
|
const constructedPath = basePath
|
||||||
? parse(`${basePath}/${path}`).pathname ?? ''
|
? parse(`${basePath}/${path}`).pathname ?? ''
|
||||||
: path;
|
: path;
|
||||||
|
|
||||||
return !!matchPath(constructedPath, location.pathname);
|
return !!matchPath(constructedPath, location.pathname);
|
||||||
};
|
},
|
||||||
|
[location.pathname],
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { useCallback } from 'react';
|
||||||
import { isNonEmptyString } from '@sniptt/guards';
|
import { isNonEmptyString } from '@sniptt/guards';
|
||||||
import { useRecoilState, useRecoilValue } from 'recoil';
|
import { useRecoilState, useRecoilValue } from 'recoil';
|
||||||
|
|
||||||
@ -32,7 +33,8 @@ export const useOpenCreateActivityDrawer = () => {
|
|||||||
);
|
);
|
||||||
const [, setViewableActivityId] = useRecoilState(viewableActivityIdState);
|
const [, setViewableActivityId] = useRecoilState(viewableActivityIdState);
|
||||||
|
|
||||||
return async ({
|
return useCallback(
|
||||||
|
async ({
|
||||||
type,
|
type,
|
||||||
targetableEntities,
|
targetableEntities,
|
||||||
assigneeId,
|
assigneeId,
|
||||||
@ -74,5 +76,12 @@ export const useOpenCreateActivityDrawer = () => {
|
|||||||
setViewableActivityId(createdActivity.id);
|
setViewableActivityId(createdActivity.id);
|
||||||
setActivityTargetableEntityArray(targetableEntities ?? []);
|
setActivityTargetableEntityArray(targetableEntities ?? []);
|
||||||
openRightDrawer(RightDrawerPages.CreateActivity);
|
openRightDrawer(RightDrawerPages.CreateActivity);
|
||||||
};
|
},
|
||||||
|
[
|
||||||
|
openRightDrawer,
|
||||||
|
setActivityTargetableEntityArray,
|
||||||
|
setHotkeyScope,
|
||||||
|
setViewableActivityId,
|
||||||
|
],
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { useCallback } from 'react';
|
||||||
import { useRecoilCallback, useSetRecoilState } from 'recoil';
|
import { useRecoilCallback, useSetRecoilState } from 'recoil';
|
||||||
|
|
||||||
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
||||||
@ -38,9 +39,12 @@ export const useCommandMenu = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const addToCommandMenu = (addCommand: Command[]) => {
|
const addToCommandMenu = useCallback(
|
||||||
|
(addCommand: Command[]) => {
|
||||||
setCommands((prev) => [...prev, ...addCommand]);
|
setCommands((prev) => [...prev, ...addCommand]);
|
||||||
};
|
},
|
||||||
|
[setCommands],
|
||||||
|
);
|
||||||
|
|
||||||
const setToIntitialCommandMenu = () => {
|
const setToIntitialCommandMenu = () => {
|
||||||
setCommands(commandMenuCommands);
|
setCommands(commandMenuCommands);
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { useCallback } from 'react';
|
||||||
import { useRecoilCallback } from 'recoil';
|
import { useRecoilCallback } from 'recoil';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
@ -36,18 +37,19 @@ export const useSnackBar = () => {
|
|||||||
queue: [...prev.queue, newValue] as SnackBarOptions[],
|
queue: [...prev.queue, newValue] as SnackBarOptions[],
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
[scopeId],
|
||||||
);
|
);
|
||||||
|
|
||||||
const enqueueSnackBar = (
|
const enqueueSnackBar = useCallback(
|
||||||
message: string,
|
(message: string, options?: Omit<SnackBarOptions, 'message' | 'id'>) => {
|
||||||
options?: Omit<SnackBarOptions, 'message' | 'id'>,
|
|
||||||
) => {
|
|
||||||
setSnackBarQueue({
|
setSnackBarQueue({
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
message,
|
message,
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
};
|
},
|
||||||
|
[setSnackBarQueue],
|
||||||
|
);
|
||||||
|
|
||||||
return { handleSnackBarClose, enqueueSnackBar };
|
return { handleSnackBarClose, enqueueSnackBar };
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user