fix cache bug with signout

This commit is contained in:
Roland Osborne 2022-05-15 23:33:17 -07:00
parent 754b94fcd9
commit bda3eb609a
7 changed files with 38 additions and 3 deletions

View File

@ -34,9 +34,13 @@ export function useAccountContext() {
}
const actions = {
setToken: async (token) => {
setToken: (token) => {
access.current = token;
},
clearToken: () => {
access.current = null;
setState({ init: false });
},
setRevision: async (rev) => {
setStatus(rev);
},

View File

@ -39,6 +39,7 @@ export function useAppContext() {
const updateState = (value) => {
setState((s) => ({ ...s, ...value }))
}
const updateData = (value) => {
setState((s) => {
let data = { ...s.Data, ...value }
@ -55,6 +56,12 @@ export function useAppContext() {
const resetData = () => {
revision.current = null;
accountContext.actions.clearToken();
profileContext.actions.clearToken();
articleContext.actions.clearToken();
groupContext.actions.clearToken();
cardContext.actions.clearToken();
channelContext.actions.clearToken();
setState({});
}

View File

@ -17,6 +17,9 @@ export function useArticleContext() {
setToken: (token) => {
updateState({ token });
},
clearToken: () => {
setState({ init: false });
},
setRevision: async (revision) => {
updateState({ revision });
},

View File

@ -183,9 +183,15 @@ export function useCardContext() {
}
const actions = {
setToken: async (token) => {
setToken: (token) => {
access.current = token;
},
clearToken: () => {
access.current = null;
cards.current = new Map();
revision.current = null;
setState({ init: false, cards: new Map() });
},
setRevision: async (rev) => {
setCards(rev);
},

View File

@ -83,6 +83,12 @@ export function useChannelContext() {
setToken: (token) => {
access.current = token;
},
clearToken: () => {
access.current = null;
channels.current = new Map();
revision.current = null;
setState({ init: false, channels: new Map() });
},
setRevision: async (rev) => {
setChannels(rev);
},

View File

@ -46,9 +46,13 @@ export function useGroupContext() {
}
const actions = {
setToken: async (token) => {
setToken: (token) => {
access.current = token;
},
clearToken: () => {
access.current = null;
setState({ init: false });
},
setRevision: async (rev) => {
setGroups(rev);
},

View File

@ -39,6 +39,11 @@ export function useProfileContext() {
setToken: (token) => {
access.current = token;
},
clearToken: () => {
access.current = null;
revision.current = null;
setState({ init: false, profile: {} });
},
setRevision: (rev) => {
setProfile(rev);
},