mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-17 01:59:08 +00:00
add an instant cache refresh to the editor
This commit is contained in:
parent
68b2b7323b
commit
0836d548b2
6 changed files with 66 additions and 11 deletions
|
@ -19,12 +19,14 @@ type GuildContextT = {
|
|||
) => Promise<PresentableGuild | null | false>;
|
||||
getGuildSlug: (id: string) => Promise<GuildSlug | null>;
|
||||
uncacheGuild: (id: string) => void;
|
||||
uncacheRemoteGuild: (id: string) => Promise<void>;
|
||||
};
|
||||
|
||||
export const GuildContext = React.createContext<GuildContextT>({
|
||||
getFullGuild: (id: string) => Promise.reject(new Error('Not implemented')),
|
||||
getGuildSlug: (id: string) => Promise.reject(new Error('Not implemented')),
|
||||
uncacheGuild: (id: string) => {},
|
||||
uncacheGuild: (id: string) => void 0,
|
||||
uncacheRemoteGuild: (id: string) => Promise.resolve(void 0),
|
||||
});
|
||||
|
||||
export const useGuildContext = () => React.useContext(GuildContext);
|
||||
|
@ -108,6 +110,9 @@ export const GuildProvider = (props: { children: React.ReactNode }) => {
|
|||
uncacheGuild: (id: string) => {
|
||||
sessionStorage.removeItem(`guild-${id}`);
|
||||
},
|
||||
uncacheRemoteGuild: async (id: string) => {
|
||||
await authedFetch(`/guilds/${id}/cache`, { method: 'DELETE' });
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue