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 <ChristophWurst@users.noreply.github.com>2021-10-13 10:50:35 +0300
committerGitHub <noreply@github.com>2021-10-13 10:50:35 +0300
commitde557bc4ab8d52868a188a8fc28c88a1e49cd38d (patch)
tree2bc195f7e5be0892753701c17a3d3e0590026d44 /src
parent70aebeeeb7b6a9dd21298f4353d34da96bf8b8bd (diff)
parent58e04077cfed49f084d690f243872b0b52130b92 (diff)
Merge pull request #5600 from nextcloud/fix/unified-inboxes-too-many-envelopes
Prevent irrelevant envelopes entering the unified mailboxes
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,