mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 00:24:53 +00:00
Added creating family devices, refetch calendar on notification received
This commit is contained in:
@ -9,11 +9,14 @@ import * as Notifications from 'expo-notifications';
|
||||
import * as Device from 'expo-device';
|
||||
import Constants from 'expo-constants';
|
||||
import { Platform } from 'react-native';
|
||||
import {useQueryClient} from "react-query";
|
||||
|
||||
|
||||
export enum ProfileType {
|
||||
"PARENT" = "parent",
|
||||
"CHILD" = "child",
|
||||
"CAREGIVER" = "caregiver"
|
||||
"CAREGIVER" = "caregiver",
|
||||
FAMILY_DEVICE = "FAMILY_DEVICE"
|
||||
}
|
||||
|
||||
interface IAuthContext {
|
||||
@ -91,6 +94,8 @@ export const AuthContextProvider: FC<{ children: ReactNode }> = ({children}) =>
|
||||
const {replace} = useRouter();
|
||||
const ready = !initializing;
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const onAuthStateChangedHandler = async (authUser: FirebaseAuthTypes.User | null) => {
|
||||
setUser(authUser);
|
||||
|
||||
@ -153,6 +158,17 @@ export const AuthContextProvider: FC<{ children: ReactNode }> = ({children}) =>
|
||||
}
|
||||
}, [user, ready]);
|
||||
|
||||
useEffect(() => {
|
||||
const sub = Notifications.addNotificationReceivedListener(notification => {
|
||||
const eventId = notification?.request?.content?.data?.eventId;
|
||||
|
||||
if (eventId) {
|
||||
queryClient.invalidateQueries(['events']);
|
||||
}
|
||||
});
|
||||
return () => sub.remove()
|
||||
}, []);
|
||||
|
||||
if (!ready) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user