Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Commit

Permalink
fix: cache and check on login
Browse files Browse the repository at this point in the history
  • Loading branch information
dastrong-codiga committed Jan 21, 2023
1 parent d41a6dc commit 8061e43
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"coding-assistant",
"codiga"
],
"version": "0.0.17",
"version": "0.0.18",
"homepage": "https://www.codiga.io/",
"bugs": {
"url": "https://github.com/codiga/code-snippets-manager/issues"
Expand Down
2 changes: 1 addition & 1 deletion release/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codiga",
"version": "0.0.17",
"version": "0.0.18",
"description": "Codiga Code Snippets Manager",
"license": "MIT",
"author": {
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/components/Layout/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export default function SideMenu({ openLoginModal }: SideMenuProps) {
localStorage.removeItem(TOKEN);
setUser({});
navigate('/');
await apolloClient.clearStore();
await apolloClient.cache.reset();
await apolloClient.resetStore();
} catch (err) {
// eslint-disable-next-line no-console
Expand Down
7 changes: 5 additions & 2 deletions src/renderer/components/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ export default function Login({ isOpen, closeModal }: LoginProps) {
// set the token in localStorarge, which the apollo client will grab
localStorage.setItem(TOKEN, formData.token);
// check if a user is returned now
const { data } = await validateToken();
const { data, error } = await validateToken({
fetchPolicy: 'network-only',
nextFetchPolicy: 'network-only',
});
// valid token, close/reset modal, otherwise remove token and show an error to the user
if (data?.user) {
if (data?.user && !error) {
setUser(data.user);
closeAndReset();
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/UserContext/UserContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const UserProvider = ({ children }: { children: ReactNode }) => {

useQuery<{ user: Partial<User> }>(CHECK_USER, {
pollInterval: POLL_USER_FOR_LOGOUT_MSEC,
fetchPolicy: 'no-cache',
fetchPolicy: 'network-only',
nextFetchPolicy: 'network-only',
onCompleted: (respData) => {
if (respData?.user) {
setUser(respData?.user);
Expand Down

0 comments on commit 8061e43

Please sign in to comment.