Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong attendance status for imip events #10024

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -134,9 +134,9 @@
/**
* Search a vEvent for an attendee by mail.
*
* @param {EventComponent|undefined|null} vEvent The event providing the attendee haystack.

Check warning on line 137 in src/components/Imip.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The type 'EventComponent' is undefined
* @param {string} email The email address (with or without a mailto prefix) to use as the needle.
* @return {AttendeeProperty|undefined} The attendee property or undefined if the given email is not matching an attendee.

Check warning on line 139 in src/components/Imip.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The type 'AttendeeProperty' is undefined
*/
function findAttendee(vEvent, email) {
if (!vEvent) {
Expand Down Expand Up @@ -191,7 +191,7 @@
computed: {
...mapGetters({
currentUserPrincipalEmail: 'getCurrentUserPrincipalEmail',
clonedCalendars: 'getClonedCalendars',
clonedWriteableCalendars: 'getClonedWriteableCalendars',
}),

/**
Expand Down Expand Up @@ -241,7 +241,7 @@
},

/**
* @return {CalendarComponent|undefined}

Check warning on line 244 in src/components/Imip.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The type 'CalendarComponent' is undefined
*/
attachedVCalendar() {
const parserManager = getParserManager()
Expand All @@ -253,14 +253,14 @@
},

/**
* @return {EventComponent|undefined}

Check warning on line 256 in src/components/Imip.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The type 'EventComponent' is undefined
*/
attachedVEvent() {
return this.attachedVCalendar?.getFirstComponent('VEVENT') ?? undefined
},

/**
* @return {CalendarComponent|undefined}

Check warning on line 263 in src/components/Imip.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The type 'CalendarComponent' is undefined
*/
existingVCalendar() {
if (!this.existingEvent) {
Expand All @@ -276,7 +276,7 @@
},

/**
* @return {EventComponent|undefined}

Check warning on line 279 in src/components/Imip.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The type 'EventComponent' is undefined
*/
existingVEvent() {
return this.existingVCalendar?.getFirstComponent('VEVENT') ?? undefined
Expand Down Expand Up @@ -362,7 +362,7 @@
}
}

return this.clonedCalendars
return this.clonedWriteableCalendars
.map(getCalendarData)
.filter(props => props.components.vevent && props.writable === true)
},
Expand All @@ -374,12 +374,6 @@
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 @@

// 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 @@ -130,6 +130,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
},
}
Loading