From 2929dd147ca38fa2bedd32fb23aa76ed9a047f09 Mon Sep 17 00:00:00 2001 From: Naveen Date: Wed, 27 Sep 2023 23:25:08 +0530 Subject: [PATCH] Update Attendee.isMe when synchronising --- .../calendar/pro/helpers/CalDAVHelper.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt index f0f577e39..b5e3a2e87 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt @@ -44,7 +44,7 @@ class CalDAVHelper(val context: Context) { } } - fetchCalDAVCalendarEvents(calendar.id, localEventType.id!!, showToasts) + fetchCalDAVCalendarEvents(calendar, localEventType.id!!, showToasts) } if (scheduleNextSync) { @@ -149,7 +149,9 @@ class CalDAVHelper(val context: Context) { } @SuppressLint("MissingPermission") - private fun fetchCalDAVCalendarEvents(calendarId: Int, eventTypeId: Long, showToasts: Boolean) { + private fun fetchCalDAVCalendarEvents(calendar: CalDAVCalendar, eventTypeId: Long, showToasts: Boolean) { + val calendarId = calendar.id + val importIdsMap = HashMap() val fetchedEventIds = ArrayList() @@ -211,7 +213,7 @@ class CalDAVHelper(val context: Context) { val originalId = cursor.getStringValue(Events.ORIGINAL_ID) val originalInstanceTime = cursor.getLongValue(Events.ORIGINAL_INSTANCE_TIME) val reminders = getCalDAVEventReminders(id) - val attendees = getCalDAVEventAttendees(id) + val attendees = getCalDAVEventAttendees(id, calendar) val availability = cursor.getIntValue(Events.AVAILABILITY) val status = cursor.getIntValue(Events.STATUS) val color = cursor.getIntValueOrNull(Events.EVENT_COLOR) @@ -570,7 +572,7 @@ class CalDAVHelper(val context: Context) { return reminders.sortedBy { it.minutes } } - private fun getCalDAVEventAttendees(eventId: Long): List { + private fun getCalDAVEventAttendees(eventId: Long, calendar: CalDAVCalendar): List { val attendees = ArrayList() val uri = Attendees.CONTENT_URI val projection = arrayOf( @@ -585,7 +587,7 @@ class CalDAVHelper(val context: Context) { val email = cursor.getStringValue(Attendees.ATTENDEE_EMAIL) ?: "" val status = cursor.getIntValue(Attendees.ATTENDEE_STATUS) val relationship = cursor.getIntValue(Attendees.ATTENDEE_RELATIONSHIP) - val attendee = Attendee(0, name, email, status, "", false, relationship) + val attendee = Attendee(0, name, email, status, "", email == calendar.ownerName, relationship) attendees.add(attendee) }