Skip to content

Commit

Permalink
[AppLayout] load blockedReason and set cookie & reload if current use…
Browse files Browse the repository at this point in the history
…r has blockedReason
  • Loading branch information
MrOrz committed Nov 29, 2021
1 parent 440e519 commit abba9a8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions components/AppLayout/AppLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import UpgradeDialog from './UpgradeDialog';
import { useLazyQuery } from '@apollo/react-hooks';
import LoginModal from './LoginModal';
import fetchAPI from 'lib/fetchAPI';
import { blockUserBrowserAndRefreshIfNeeded } from 'lib/isUserBlocked';
import Snackbar from '@material-ui/core/Snackbar';

const USER_QUERY = gql`
query AppLayoutQuery {
GetUser {
...AppSidebarUserData
...AppHeaderUserData
blockedReason
}
}
${AppSidebar.fragments.AppSidebarUserData}
Expand Down Expand Up @@ -73,6 +75,15 @@ function AppLayout({ children, container = true }) {
};
}, []);

// Mark blocked user's browser with cookie
//
const hasBlockedReason = !!data?.GetUser?.blockedReason;
useEffect(() => {
if (hasBlockedReason) {
blockUserBrowserAndRefreshIfNeeded();
}
}, [hasBlockedReason]);

return (
<Fragment>
<AppHeader
Expand Down

0 comments on commit abba9a8

Please sign in to comment.