Skip to content

Commit

Permalink
Limit mails when applying label
Browse files Browse the repository at this point in the history
  • Loading branch information
BijinDev authored and charlag committed Nov 11, 2024
1 parent 9ad79c3 commit 79fe875
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/tutanota-utils/lib/ArrayUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,15 @@ export function collectToMap<T, R>(iterable: Iterable<T>, keyExtractor: (element
* @param array
* @returns {Array<Array<T>>}
*/
export function splitInChunks<T>(chunkSize: number, array: Array<T>): Array<Array<T>> {
export function splitInChunks<T>(chunkSize: number, array: ReadonlyArray<T>): Array<Array<T>> {
return downcast(_chunk(chunkSize, array))
}

export function splitUint8ArrayInChunks(chunkSize: number, array: Uint8Array): Array<Uint8Array> {
return downcast(_chunk(chunkSize, array))
}

function _chunk<T>(chunkSize: number, array: Array<T> | Uint8Array): Array<Array<T> | Uint8Array> {
function _chunk<T>(chunkSize: number, array: ReadonlyArray<T> | Uint8Array): Array<Array<T> | Uint8Array> {
if (chunkSize < 1) {
return []
}
Expand Down
5 changes: 4 additions & 1 deletion src/mail-app/mail/model/MailModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,10 @@ export class MailModel {
}

async applyLabels(mails: readonly Mail[], addedLabels: readonly MailFolder[], removedLabels: readonly MailFolder[]): Promise<void> {
await this.mailFacade.applyLabels(mails, addedLabels, removedLabels)
const mailChunks = splitInChunks(MAX_NBR_MOVE_DELETE_MAIL_SERVICE, mails)
for (const mailChunk of mailChunks) {
await this.mailFacade.applyLabels(mailChunk, addedLabels, removedLabels)
}
}

_mailboxCountersUpdates(counters: WebsocketCounterData) {
Expand Down

0 comments on commit 79fe875

Please sign in to comment.