sync update

This commit is contained in:
Milan Paunovic
2024-11-02 22:27:17 +01:00
parent 8a0370933d
commit f1b0bcd32d
6 changed files with 221 additions and 118 deletions

View File

@ -82,6 +82,8 @@ export const useCalSync = () => {
[googleMail]: {accessToken, refreshToken},
};
console.log({refreshToken})
await updateUserData({
newUserData: {googleAccounts: updatedGoogleAccounts},
});
@ -243,8 +245,11 @@ export const useCalSync = () => {
const syncPromises: Promise<void>[] = [];
if (profileData?.googleAccounts) {
for (const [email, { accessToken, refreshToken }] of Object.entries(profileData.googleAccounts)) {
syncPromises.push(fetchAndSaveGoogleEvents({ token: accessToken, refreshToken, email }));
console.log(profileData.googleAccounts)
for (const [email, emailAcc] of Object.entries(profileData.googleAccounts)) {
if(emailAcc?.accessToken) {
syncPromises.push(fetchAndSaveGoogleEvents({ token: emailAcc?.accessToken, refreshToken: emailAcc?.refreshToken, email }));
}
}
}
@ -304,7 +309,7 @@ export const useCalSync = () => {
const eventId = notification?.request?.content?.data?.eventId;
await resyncAllCalendars();
queryClient.invalidateQueries(["events"]);
// queryClient.invalidateQueries(["events"]);
};
const sub = Notifications.addNotificationReceivedListener(handleNotification);