Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2021-08-31 18:42:11 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2022-06-01 10:17:20 +0300
commita56f68d9ba55a5986d2f0d3e865dff7f3115aeab (patch)
treeb0ad0c585d40571ac3bf887d9ffdeaa4534d487e
parent1a0e6195875307d8bc03ed48e5b3d8a83c328efd (diff)
Add getEnvelopesByThreadRootId to select messages from store by thread root id
Difference to getEnvelopeThread is that store.envelopes is used instead of the threads list inside a given envelope. Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
-rw-r--r--src/components/Thread.vue9
-rw-r--r--src/store/getters.js8
-rw-r--r--src/tests/unit/store/getters.spec.js65
3 files changed, 76 insertions, 6 deletions
diff --git a/src/components/Thread.vue b/src/components/Thread.vue
index 5bbfea372..15dea0cdb 100644
--- a/src/components/Thread.vue
+++ b/src/components/Thread.vue
@@ -91,13 +91,16 @@ export default {
return parseInt(this.$route.params.threadId, 10)
},
thread() {
- const envelopes = this.$store.getters.getEnvelopeThread(this.threadId)
- const envelope = envelopes.find(envelope => envelope.databaseId === this.threadId)
-
+ const envelope = this.$store.getters.getEnvelope(this.threadId)
if (envelope === undefined) {
return []
}
+ const envelopes = this.$store.getters.getEnvelopesByThreadRootId(envelope.accountId, envelope.threadRootId)
+ if (envelopes.length === 0) {
+ return []
+ }
+
const currentMailbox = this.$store.getters.getMailbox(envelope.mailboxId)
const trashMailbox = this.$store.getters.getMailboxes(currentMailbox.accountId).find(mailbox => mailbox.specialRole === 'trash')
diff --git a/src/store/getters.js b/src/store/getters.js
index 9e4e59518..6d5204fd6 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { defaultTo, head, sortBy, prop } from 'ramda'
+import { defaultTo, head, prop, sortBy } from 'ramda'
import { UNIFIED_ACCOUNT_ID } from './constants'
import { normalizedEnvelopeListId } from './normalization'
@@ -70,6 +70,12 @@ export const getters = {
const list = getters.getMailbox(mailboxId).envelopeLists[normalizedEnvelopeListId(query)] || []
return list.map((msgId) => state.envelopes[msgId])
},
+ getEnvelopesByThreadRootId: (state) => (accountId, threadRootId) => {
+ return sortBy(
+ prop('dateInt'),
+ Object.values(state.envelopes).filter(envelope => envelope.accountId === accountId && envelope.threadRootId === threadRootId)
+ )
+ },
getMessage: (state) => (id) => {
return state.messages[id]
},
diff --git a/src/tests/unit/store/getters.spec.js b/src/tests/unit/store/getters.spec.js
index 3d6d70493..bc9798c1a 100644
--- a/src/tests/unit/store/getters.spec.js
+++ b/src/tests/unit/store/getters.spec.js
@@ -91,7 +91,7 @@ describe('Vuex store getters', () => {
1,
2,
3,
- ]
+ ],
}
state.envelopes[2] = {
databaseId: 1,
@@ -117,7 +117,7 @@ describe('Vuex store getters', () => {
1,
2,
3,
- ]
+ ],
},
{
databaseId: 1,
@@ -131,4 +131,65 @@ describe('Vuex store getters', () => {
},
])
})
+
+ it('return envelopes by thread root id', () => {
+ state.envelopes[0] = {
+ accountId: 1,
+ databaseId: 1,
+ uid: 101,
+ mailboxId: 13,
+ threadRootId: '123-456-789',
+ }
+ state.envelopes[1] = {
+ accountId: 1,
+ databaseId: 2,
+ uid: 102,
+ mailboxId: 13,
+ threadRootId: '123-456-789',
+ }
+ state.envelopes[2] = {
+ accountId: 1,
+ databaseId: 3,
+ uid: 103,
+ mailboxId: 13,
+ threadRootId: '234-567-890',
+ }
+ state.envelopes[3] = {
+ accountId: 1,
+ databaseId: 4,
+ uid: 104,
+ mailboxId: 13,
+ threadRootId: '234-567-890',
+ }
+ state.envelopes[4] = {
+ accountId: 2,
+ databaseId: 5,
+ uid: 105,
+ mailboxId: 23,
+ threadRootId: '123-456-789',
+ }
+ const getters = bindGetters()
+
+ const envelopesA = getters.getEnvelopesByThreadRootId(1, '123-456-789')
+ expect(envelopesA).to.be.length(2)
+ expect(envelopesA).to.deep.equal([
+ {
+ accountId: 1,
+ databaseId: 1,
+ uid: 101,
+ mailboxId: 13,
+ threadRootId: '123-456-789',
+ },
+ {
+ accountId: 1,
+ databaseId: 2,
+ uid: 102,
+ mailboxId: 13,
+ threadRootId: '123-456-789',
+ },
+ ])
+
+ const envelopesB = getters.getEnvelopesByThreadRootId('345-678-901')
+ expect(envelopesB).to.be.empty
+ })
})