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 redirect after moving thread envelope #3915

Merged
merged 1 commit into from
Nov 3, 2020
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
2 changes: 1 addition & 1 deletion src/components/MoveModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export default {
.map((envelope) => envelope.databaseId)

if (envelopeIds.length === 0) {
this.$emit('close')
return
}

Expand All @@ -64,6 +63,7 @@ export default {
}))

await this.$store.dispatch('syncEnvelopes', { mailboxId: this.destMailboxId })
this.$emit('move')
} catch (error) {
logger.error('could not move messages', {
error,
Expand Down
30 changes: 25 additions & 5 deletions src/components/Thread.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
:envelope="env"
:mailbox-id="$route.params.mailboxId"
:expanded="expandedThreads.includes(env.databaseId)"
@move="onMove(env.databaseId)"
@toggleExpand="toggleExpand(env.databaseId)" />
</template>
</AppContentDetails>
Expand Down Expand Up @@ -54,8 +55,11 @@ export default {
}
},
computed: {
threadId() {
return parseInt(this.$route.params.threadId, 10)
},
thread() {
return this.$store.getters.getEnvelopeThread(this.$route.params.threadId)
return this.$store.getters.getEnvelopeThread(this.threadId)
},
threadParticipants() {
const recipients = this.thread.flatMap(envelope => {
Expand Down Expand Up @@ -84,11 +88,11 @@ export default {
return
}
logger.debug('navigated to another thread', { to, from })
this.fetchThread()
this.resetThread()
},
},
created() {
this.fetchThread()
this.resetThread()
},
methods: {
toggleExpand(threadId) {
Expand All @@ -100,12 +104,28 @@ export default {
this.expandedThreads = this.expandedThreads.filter(t => t !== threadId)
}
},
onMove(threadId) {
if (threadId === this.threadId) {
this.$router.replace({
name: 'mailbox',
params: {
mailboxId: this.$route.params.mailboxId,
},
})
} else {
this.expandedThreads = this.expandedThreads.filter((id) => id !== threadId)
this.fetchThread()
}
},
async resetThread() {
this.expandedThreads = [this.threadId]
await this.fetchThread()
},
async fetchThread() {
this.loading = true
this.errorMessage = ''
this.error = undefined
const threadId = parseInt(this.$route.params.threadId, 10)
this.expandedThreads = [threadId]
const threadId = this.threadId

try {
const thread = await this.$store.dispatch('fetchThread', threadId)
Expand Down
10 changes: 4 additions & 6 deletions src/components/ThreadEnvelope.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
v-if="showMoveModal"
:account="account"
:envelopes="[envelope]"
@move="onMove"
@close="onCloseMoveModal" />
</div>
</div>
Expand Down Expand Up @@ -363,12 +364,9 @@ export default {
},
onCloseMoveModal() {
this.showMoveModal = false
this.$router.replace({
name: 'mailbox',
params: {
mailboxId: this.$route.params.mailboxId,
},
})
},
onMove() {
this.$emit('move')
},
},
}
Expand Down