mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 00:24:53 +00:00
sync update
This commit is contained in:
@ -17,20 +17,23 @@ export const useClearTokens = () => {
|
||||
if (provider === "google") {
|
||||
let googleAccounts = profileData?.googleAccounts;
|
||||
if (googleAccounts) {
|
||||
googleAccounts[email] = null;
|
||||
newUserData.googleAccounts = googleAccounts;
|
||||
const newGoogleAccounts = {...googleAccounts}
|
||||
delete newGoogleAccounts[email];
|
||||
newUserData.googleAccounts = newGoogleAccounts;
|
||||
}
|
||||
} else if (provider === "outlook") {
|
||||
let microsoftAccounts = profileData?.microsoftAccounts;
|
||||
if (microsoftAccounts) {
|
||||
microsoftAccounts[email] = null;
|
||||
newUserData.microsoftAccounts = microsoftAccounts;
|
||||
const newMicrosoftAccounts = {...microsoftAccounts}
|
||||
delete microsoftAccounts[email];
|
||||
newUserData.microsoftAccounts = newMicrosoftAccounts;
|
||||
}
|
||||
} else if (provider === "apple") {
|
||||
let appleAccounts = profileData?.appleAccounts;
|
||||
if (appleAccounts) {
|
||||
appleAccounts[email] = null;
|
||||
newUserData.appleAccounts = appleAccounts;
|
||||
const newAppleAccounts = {...appleAccounts}
|
||||
delete newAppleAccounts[email];
|
||||
newUserData.appleAccounts = newAppleAccounts;
|
||||
}
|
||||
}
|
||||
await updateUserData({newUserData});
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user