Skip to content

Commit

Permalink
perf: skip non-writable calendars
Browse files Browse the repository at this point in the history
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 <mail@danielkesselberg.de>

[skip ci]
  • Loading branch information
kesselb authored and backportbot[bot] committed Sep 3, 2024
1 parent b990d8f commit 030a6a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/Imip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default {
computed: {
...mapGetters({
currentUserPrincipalEmail: 'getCurrentUserPrincipalEmail',
clonedCalendars: 'getClonedCalendars',
clonedWriteableCalendars: 'getClonedWriteableCalendars',
}),
/**
Expand Down Expand Up @@ -379,7 +379,7 @@ export default {
}
}
return this.clonedCalendars
return this.clonedWriteableCalendars
.map(getCalendarData)
.filter(props => props.components.vevent && props.writable === true)
},
Expand Down Expand Up @@ -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'],
Expand Down
4 changes: 3 additions & 1 deletion src/store/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 030a6a4

Please sign in to comment.