mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 00:24:53 +00:00
Small fixes, calendar token refresh for google
This commit is contained in:
@ -2,8 +2,9 @@ import * as Calendar from 'expo-calendar';
|
||||
|
||||
export async function fetchiPhoneCalendarEvents(familyId, email, startDate, endDate) {
|
||||
try {
|
||||
const {status} = await Calendar.requestCalendarPermissionsAsync();
|
||||
if (status !== 'granted') {
|
||||
const {granted} = await Calendar.requestCalendarPermissionsAsync();
|
||||
|
||||
if (!granted) {
|
||||
throw new Error("Calendar permission not granted");
|
||||
}
|
||||
|
||||
@ -22,7 +23,11 @@ export async function fetchiPhoneCalendarEvents(familyId, email, startDate, endD
|
||||
return events.map((event) => {
|
||||
let isAllDay = event.allDay || false;
|
||||
const startDateTime = new Date(event.startDate);
|
||||
const endDateTime = new Date(event.endDate);
|
||||
let endDateTime = new Date(event.endDate);
|
||||
|
||||
if (isAllDay) {
|
||||
endDateTime = startDateTime
|
||||
}
|
||||
|
||||
return {
|
||||
id: event.id,
|
||||
|
||||
@ -8,7 +8,9 @@ export async function fetchGoogleCalendarEvents(token, email, familyId, startDat
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
const googleEvents = [];
|
||||
data.items?.forEach((item) => {
|
||||
let isAllDay = false;
|
||||
@ -49,5 +51,5 @@ export async function fetchGoogleCalendarEvents(token, email, familyId, startDat
|
||||
googleEvents.push(googleEvent);
|
||||
});
|
||||
|
||||
return googleEvents;
|
||||
return {googleEvents, success: response.ok};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user