From 451b4c31e2d3b1bd4eb7f11756b37fc281496283 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Tue, 20 Aug 2024 13:46:20 +0200 Subject: [PATCH] perf: skip non-writable calendars Accepting a calendar invitation should always go to a writable calendar, and therefore we can skip the check if the event exists in a read-only calendar. Signed-off-by: Daniel Kesselberg --- src/components/Imip.vue | 6 +++--- src/store/getters.js | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/Imip.vue b/src/components/Imip.vue index bcd10d227c..518f32f4bf 100644 --- a/src/components/Imip.vue +++ b/src/components/Imip.vue @@ -208,7 +208,7 @@ export default { computed: { ...mapGetters({ currentUserPrincipalEmail: 'getCurrentUserPrincipalEmail', - clonedCalendars: 'getClonedCalendars', + clonedWriteableCalendars: 'getClonedWriteableCalendars', }), /** @@ -379,7 +379,7 @@ export default { } } - return this.clonedCalendars + return this.clonedWriteableCalendars .map(getCalendarData) .filter(props => props.components.vevent && props.writable === true) }, @@ -487,7 +487,7 @@ export default { // TODO: can this query be reduced to a single request? const limit = pLimit(5) - const promises = this.clonedCalendars.map(async (calendar) => { + const promises = this.clonedWriteableCalendars.map(async (calendar) => { // Query adapted from https://datatracker.ietf.org/doc/html/rfc4791#section-7.8.6 return limit(() => calendar.calendarQuery([{ name: [NS.IETF_CALDAV, 'comp-filter'], diff --git a/src/store/getters.js b/src/store/getters.js index 659fe0db9c..431ca6d6ee 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -123,7 +123,9 @@ export const getters = { getCurrentUserPrincipal: (state) => state.currentUserPrincipal, getCurrentUserPrincipalEmail: (state) => state.currentUserPrincipal?.email, getCalendars: (state) => state.calendars, - getClonedCalendars: (state) => state.calendars.map(calendar => { + getClonedWriteableCalendars: (state) => state.calendars.filter(calendar => { + return calendar.isWriteable() + }).map(calendar => { // Hack: We need to clone all calendars because some methods (e.g. calendarQuery) are // unnecessarily mutating the object and causing vue warnings (if used outside of // mutations).