Skip to content

Commit

Permalink
fix: fetch attendance status when calendars are loaded
Browse files Browse the repository at this point in the history
One may have imported an event, but the attendance status is not properly fetched when rendering the email.
The reason is a timing / state problem.

- Loading the user principal and collections is initialized in https://github.com/nextcloud/mail/blob/6fc45eb0630b9065f9ccb4c1da5cc9557f7df834/src/App.vue#L49-L50.
- If the backend request for the message body is faster, than loading the principal and collections, then Imip.fetchExistingEvent runs without having calendars and changes existingEventFetched to true that prevents the method from running again.
- Solution: Render the imip component when principal and collections are fetched.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
kesselb committed Sep 4, 2024
1 parent 9329bf2 commit b1d6c90
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default {
this.sync()
await this.$store.dispatch('fetchCurrentUserPrincipal')
await this.$store.dispatch('loadCollections')
this.$store.commit('hasCurrentUserPrincipalAndCollections', true)
},
methods: {
reload() {
Expand Down
6 changes: 0 additions & 6 deletions src/components/Imip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,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
5 changes: 4 additions & 1 deletion src/components/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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 @@ -144,6 +144,9 @@ export default {
itineraries() {
return this.message.itineraries ?? []
},
hasCurrentUserPrincipalAndCollections() {
return this.$store.getters.hasCurrentUserPrincipalAndCollections
},
},
methods: {
onReply(replyBody = '') {
Expand Down
1 change: 1 addition & 0 deletions src/store/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,5 @@ export const getters = {
},
isOneLineLayout: (state) => state.list,
hasFetchedInitialEnvelopes: (state) => state.hasFetchedInitialEnvelopes,
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 @@ -108,6 +108,7 @@ export default new Store({
calendars: [],
smimeCertificates: [],
hasFetchedInitialEnvelopes: false,
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 @@ -512,4 +512,7 @@ export default {
setHasFetchedInitialEnvelopes(state, hasFetchedInitialEnvelopes) {
state.hasFetchedInitialEnvelopes = hasFetchedInitialEnvelopes
},
hasCurrentUserPrincipalAndCollections(state, hasCurrentUserPrincipalAndCollections) {
state.hasCurrentUserPrincipalAndCollections = hasCurrentUserPrincipalAndCollections
},
}

0 comments on commit b1d6c90

Please sign in to comment.