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 <[email protected]>
  • Loading branch information
kesselb committed Aug 21, 2024
1 parent 44b9a36 commit 4296585
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 @@ -191,7 +191,7 @@ export default {
computed: {
...mapGetters({
currentUserPrincipalEmail: 'getCurrentUserPrincipalEmail',
clonedCalendars: 'getClonedCalendars',
clonedWriteableCalendars: 'getClonedWriteableCalendars',
}),
/**
Expand Down Expand Up @@ -362,7 +362,7 @@ export default {
}
}
return this.clonedCalendars
return this.clonedWriteableCalendars
.map(getCalendarData)
.filter(props => props.components.vevent && props.writable === true)
},
Expand Down Expand Up @@ -470,7 +470,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 @@ -120,7 +120,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 4296585

Please sign in to comment.