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
path: root/src
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2021-09-30 15:29:38 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-10-12 15:21:27 +0300
commit58e04077cfed49f084d690f243872b0b52130b92 (patch)
treee8e5f2c897e5b5d42c386a66327127004b90d797 /src
parent659bbd048f2f1489352af4ae155eee15108a5918 (diff)
Prevent irrelevant envelopes entering the unified mailboxes
Unified mailboxes are a combination of individual mailboxes. For the first unified page we have to fetch each individual page, then combine them and take the 20 most recent messages. When fetching the individual pages we already added all envelopes to the unified mailboxes through the addEnvelope mutation. That means you already had 40 messages in the unified mailbox before they were combined and only the latest messages were picked. If you have two accounts with somewhat similarly old messages this bug doesn't always show. However, if you have one inbox with many recent messages and another inbox with only significantly older messages then this bug showed in a way that also the newest messages of the older inbox were part of the 40 first messges. Now after the fix you see the 20 new messages from the newer inbox, then 20 more of the same inbox and only when the message timestamps of the second inbox align with the first inbox you will start to see messges from the second inbox. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'src')
-rw-r--r--src/components/itinerary/CalendarImport.vue2
-rw-r--r--src/store/actions.js20
-rw-r--r--src/store/mutations.js5
-rw-r--r--src/tests/unit/store/actions.spec.js6
4 files changed, 26 insertions, 7 deletions
diff --git a/src/components/itinerary/CalendarImport.vue b/src/components/itinerary/CalendarImport.vue
index 82c1f3103..d5e8bf873 100644
--- a/src/components/itinerary/CalendarImport.vue
+++ b/src/components/itinerary/CalendarImport.vue
@@ -76,7 +76,7 @@ export default {
return dt
}
return dt['@value']
- }
+ },
}
</script>
diff --git a/src/store/actions.js b/src/store/actions.js
index 9ecf68548..399362c23 100644
--- a/src/store/actions.js
+++ b/src/store/actions.js
@@ -270,7 +270,7 @@ export default {
// Always use the object from the store
return getters.getEnvelope(id)
},
- fetchEnvelopes({ state, commit, getters, dispatch }, { mailboxId, query }) {
+ fetchEnvelopes({ state, commit, getters, dispatch }, { mailboxId, query, addToUnifiedMailboxes = true }) {
const mailbox = getters.getMailbox(mailboxId)
if (mailbox.isUnified) {
@@ -279,6 +279,7 @@ export default {
dispatch('fetchEnvelopes', {
mailboxId: mb.databaseId,
query,
+ addToUnifiedMailboxes: false,
})
),
Promise.all.bind(Promise),
@@ -312,6 +313,7 @@ export default {
commit('addEnvelope', {
query,
envelope,
+ addToUnifiedMailboxes,
})
)
)
@@ -326,7 +328,7 @@ export default {
})
return envelopes
},
- async fetchNextEnvelopes({ commit, getters, dispatch }, { mailboxId, query, quantity, rec = true }) {
+ async fetchNextEnvelopes({ commit, getters, dispatch }, { mailboxId, query, quantity, rec = true, addToUnifiedMailboxes = true }) {
const mailbox = getters.getMailbox(mailboxId)
if (mailbox.isUnified) {
@@ -354,9 +356,9 @@ export default {
// We have to fetch individual envelopes only if it ends in the known
// next fetch. If it ended before, there is no data to fetch anyway. If
// it ends after, we have all the relevant data already
- const needsFetch = curry((query, nextEnvelopes, f) => {
- const c = individualCursor(query, f)
- return nextEnvelopes.length < quantity || (c <= head(nextEnvelopes).dateInt && c >= last(nextEnvelopes).dateInt)
+ const needsFetch = curry((query, nextEnvelopes, mb) => {
+ const c = individualCursor(query, mb)
+ return nextEnvelopes.length < quantity || c >= head(nextEnvelopes).dateInt || c <= last(nextEnvelopes).dateInt
})
const mailboxesToFetch = (accounts) =>
@@ -367,12 +369,16 @@ export default {
const mbs = mailboxesToFetch(getters.accounts)
if (rec && mbs.length) {
+ logger.debug('not enough local envelopes for the next unified page. ' + mbs.length + ' fetches required', {
+ mailboxes: mbs.map(mb => mb.databaseId)
+ })
return pipe(
map((mb) =>
dispatch('fetchNextEnvelopes', {
mailboxId: mb.databaseId,
query,
quantity,
+ addToUnifiedMailboxes: false,
})
),
Promise.all.bind(Promise),
@@ -382,12 +388,14 @@ export default {
query,
quantity,
rec: false,
+ addToUnifiedMailboxes: false,
})
)
)(mbs)
}
const envelopes = nextLocalUnifiedEnvelopes(getters.accounts)
+ logger.debug('next unified page can be built locally and consists of ' + envelopes.length + ' envelopes', { addToUnifiedMailboxes })
envelopes.map((envelope) =>
commit('addEnvelope', {
query,
@@ -415,11 +423,13 @@ export default {
return fetchEnvelopes(mailbox.accountId, mailboxId, query, lastEnvelope.dateInt, quantity).then((envelopes) => {
logger.debug(`fetched ${envelopes.length} messages for mailbox ${mailboxId}`, {
envelopes,
+ addToUnifiedMailboxes,
})
envelopes.forEach((envelope) =>
commit('addEnvelope', {
query,
envelope,
+ addToUnifiedMailboxes,
})
)
return envelopes
diff --git a/src/store/mutations.js b/src/store/mutations.js
index b32e61dd8..218d6010d 100644
--- a/src/store/mutations.js
+++ b/src/store/mutations.js
@@ -170,7 +170,7 @@ export default {
}
removeRec(account)
},
- addEnvelope(state, { query, envelope }) {
+ addEnvelope(state, { query, envelope, addToUnifiedMailboxes = true }) {
normalizeTags(state, envelope)
const mailbox = state.mailboxes[envelope.mailboxId]
Vue.set(state.envelopes, envelope.databaseId, Object.assign({}, state.envelopes[envelope.databaseId] || {}, envelope))
@@ -181,6 +181,9 @@ export default {
const orderByDateInt = orderBy(idToDateInt, 'desc')
Vue.set(mailbox.envelopeLists, listId, uniq(orderByDateInt(existing.concat([envelope.databaseId]))))
+ if (!addToUnifiedMailboxes) {
+ return
+ }
const unifiedAccount = state.accounts[UNIFIED_ACCOUNT_ID]
unifiedAccount.mailboxes
.map((mbId) => state.mailboxes[mbId])
diff --git a/src/tests/unit/store/actions.spec.js b/src/tests/unit/store/actions.spec.js
index ed39187a0..1351cec27 100644
--- a/src/tests/unit/store/actions.spec.js
+++ b/src/tests/unit/store/actions.spec.js
@@ -169,6 +169,7 @@ describe('Vuex store actions', () => {
.withArgs('fetchEnvelopes', {
mailboxId: 21,
query: undefined,
+ addToUnifiedMailboxes: false,
})
.returns([
{
@@ -192,6 +193,11 @@ describe('Vuex store actions', () => {
},
])
expect(context.dispatch).to.have.been.calledOnce
+ expect(context.dispatch).to.have.been.calledWith('fetchEnvelopes', {
+ mailboxId: 21,
+ query: undefined,
+ addToUnifiedMailboxes: false,
+ })
expect(context.commit).to.have.been.calledWith('addEnvelope', {
envelope: {
databaseId: 123,