Skip to content
Snippets Groups Projects
Unverified Commit 4a318db2 authored by Christoph Wurst's avatar Christoph Wurst Committed by GitHub
Browse files

Merge pull request #2636 from nextcloud/fix/message-404-handling

Fix message not found handling
parents a7990044 24647624
No related branches found
No related tags found
No related merge requests found
...@@ -135,7 +135,7 @@ export default { ...@@ -135,7 +135,7 @@ export default {
this.fetchMessage() this.fetchMessage()
}, },
methods: { methods: {
fetchMessage() { async fetchMessage() {
this.loading = true this.loading = true
this.message = undefined this.message = undefined
this.errorMessage = '' this.errorMessage = ''
...@@ -145,51 +145,49 @@ export default { ...@@ -145,51 +145,49 @@ export default {
const messageUid = this.$route.params.messageUid const messageUid = this.$route.params.messageUid
this.$store try {
.dispatch('fetchMessage', messageUid) const message = await this.$store.dispatch('fetchMessage', messageUid)
.then(message => { // TODO: add timeout so that message isn't flagged when only viewed
// TODO: add timeout so that message isn't flagged when only viewed // for a few seconds
// for a few seconds if (message && message.uid !== this.$route.params.messageUid) {
if (message.uid !== this.$route.params.messageUid) { Logger.debug("User navigated away, loaded message won't be shown nor flagged as seen")
Logger.debug("User navigated away, loaded message won't be shown nor flagged as seen") return
return }
}
this.message = message
if (this.message === undefined) {
Logger.info('message could not be found', {messageUid})
this.errorMessage = getRandomMessageErrorMessage()
this.loading = false
return
}
const account = this.$store.getters.getAccount(message.accountId)
this.replyRecipient = buildReplyRecipients(message, {
label: account.name,
email: account.emailAddress,
})
this.replySubject = buildReplySubject(message.subject)
this.loading = false this.message = message
this.envelope = this.$store.getters.getEnvelope(message.accountId, message.folderId, message.id) if (this.message === undefined) {
if (!this.envelope.flags.unseen) { Logger.info('message could not be found', {messageUid})
// Already seen -> no change necessary this.errorMessage = getRandomMessageErrorMessage()
return this.loading = false
} return
}
return this.$store.dispatch('toggleEnvelopeSeen', this.envelope) const account = this.$store.getters.getAccount(message.accountId)
}) this.replyRecipient = buildReplyRecipients(message, {
.catch(error => { label: account.name,
Logger.error('could not load message ', {messageUid, error}) email: account.emailAddress,
if (error.isError) {
this.errorMessage = t('mail', 'Could not load your message')
this.error = error
this.loading = false
}
}) })
this.replySubject = buildReplySubject(message.subject)
this.loading = false
this.envelope = this.$store.getters.getEnvelope(message.accountId, message.folderId, message.id)
if (!this.envelope.flags.unseen) {
// Already seen -> no change necessary
return
}
return this.$store.dispatch('toggleEnvelopeSeen', this.envelope)
} catch (error) {
Logger.error('could not load message ', {messageUid, error})
if (error.isError) {
this.errorMessage = t('mail', 'Could not load your message')
this.error = error
this.loading = false
}
}
}, },
replyMessage() { replyMessage() {
this.$router.push({ this.$router.push({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment