refactor: remove get-current-user GQL query

This commit is contained in:
Rıdvan Akca
2024-03-13 12:36:11 +03:00
parent 1e868dc802
commit 082e905014
9 changed files with 20 additions and 123 deletions

View File

@@ -7,7 +7,8 @@ import useCurrentUser from 'hooks/useCurrentUser';
const Chatwoot = ({ ready }) => {
const theme = useTheme();
const { data: currentUser } = useCurrentUser();
const { data } = useCurrentUser();
const currentUser = data?.data;
const matchSmallScreens = useMediaQuery(theme.breakpoints.down('md'));
React.useEffect(function initiateChatwoot() {
@@ -24,17 +25,17 @@ const Chatwoot = ({ ready }) => {
React.useEffect(
function initiateUser() {
if (!currentUser?.data?.id || !ready) return;
window.$chatwoot.setUser(currentUser.data?.id, {
email: currentUser?.data?.email,
name: currentUser?.data?.fullName,
if (!currentUser?.id || !ready) return;
window.$chatwoot.setUser(currentUser.id, {
email: currentUser.email,
name: currentUser.fullName,
});
if (!matchSmallScreens) {
window.$chatwoot.toggleBubbleVisibility('show');
}
},
[currentUser?.data, ready, matchSmallScreens],
[currentUser, ready, matchSmallScreens],
);
React.useLayoutEffect(
function hideChatwoot() {