Skip to content

Commit

Permalink
Merge pull request #10024 from nextcloud/perf/noid/improve-imip-calen…
Browse files Browse the repository at this point in the history
…dar-integration

fix: wrong attendance status for imip events
  • Loading branch information
st3iny authored Sep 2, 2024
2 parents 1a85c25 + 4296585 commit f23e9bd
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default {
this.sync()
await this.$store.dispatch('fetchCurrentUserPrincipal')
await this.$store.dispatch('loadCollections')
this.$store.commit('hasCurrentUserPrincipalAndCollections', true)
},
methods: {
reload() {
Expand Down
12 changes: 3 additions & 9 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 All @@ -374,12 +374,6 @@ export default {
await this.fetchExistingEvent(this.attachedVEvent.uid)
},
},
clonedCalendars: {
immediate: true,
async handler() {
await this.fetchExistingEvent(this.attachedVEvent.uid)
},
},
calendarsForPicker: {
immediate: true,
handler(calendarsForPicker) {
Expand Down Expand Up @@ -476,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
5 changes: 4 additions & 1 deletion src/components/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div v-if="itineraries.length > 0" class="message-itinerary">
<Itinerary :entries="itineraries" :message-id="message.messageId" />
</div>
<div v-if="message.scheduling.length > 0" class="message-imip">
<div v-if="hasCurrentUserPrincipalAndCollections && message.scheduling.length > 0" class="message-imip">
<Imip v-for="scheduling in message.scheduling"
:key="scheduling.id"
:scheduling="scheduling" />
Expand Down Expand Up @@ -131,6 +131,9 @@ export default {
itineraries() {
return this.message.itineraries ?? []
},
hasCurrentUserPrincipalAndCollections() {
return this.$store.getters.hasCurrentUserPrincipalAndCollections
},
},
methods: {
onReply(replyBody = '') {
Expand Down
5 changes: 4 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 Expand Up @@ -156,4 +158,5 @@ export const getters = {
hasFetchedInitialEnvelopes: (state) => state.hasFetchedInitialEnvelopes,
isFollowUpFeatureAvailable: (state) => state.followUpFeatureAvailable,
getInternalAddresses: (state) => state.internalAddress?.filter(internalAddress => internalAddress !== undefined),
hasCurrentUserPrincipalAndCollections: (state) => state.hasCurrentUserPrincipalAndCollections,
}
1 change: 1 addition & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default new Store({
hasFetchedInitialEnvelopes: false,
followUpFeatureAvailable: false,
internalAddress: [],
hasCurrentUserPrincipalAndCollections: false,
},
getters,
mutations,
Expand Down
3 changes: 3 additions & 0 deletions src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,4 +513,7 @@ export default {
setFollowUpFeatureAvailable(state, followUpFeatureAvailable) {
state.followUpFeatureAvailable = followUpFeatureAvailable
},
hasCurrentUserPrincipalAndCollections(state, hasCurrentUserPrincipalAndCollections) {
state.hasCurrentUserPrincipalAndCollections = hasCurrentUserPrincipalAndCollections
},
}

0 comments on commit f23e9bd

Please sign in to comment.