Fix graphql and other things

This commit is contained in:
Gregory Schier
2023-03-15 09:06:56 -07:00
parent 951ed787fa
commit 8915915c47
15 changed files with 77 additions and 56 deletions

View File

@@ -8,12 +8,14 @@ import {
toggleAppearance,
} from '../lib/theme/window';
const appearanceQueryKey = ['theme', 'appearance'];
export function appearanceQueryKey() {
return ['theme', 'appearance'];
}
export function useTheme() {
const queryClient = useQueryClient();
const appearance = useQuery({
queryKey: appearanceQueryKey,
queryKey: appearanceQueryKey(),
queryFn: getAppearance,
initialData: getAppearance(),
}).data;
@@ -24,12 +26,10 @@ export function useTheme() {
const handleToggleAppearance = async () => {
const newAppearance = toggleAppearance();
await queryClient.setQueryData(appearanceQueryKey, newAppearance);
await queryClient.setQueryData(appearanceQueryKey(), newAppearance);
};
useEffect(() => {
return subscribeToPreferredAppearanceChange(themeChange);
}, []);
useEffect(() => subscribeToPreferredAppearanceChange(themeChange), []);
return {
appearance,