Skip to content

Commit

Permalink
perf(ThreadCell): Use realm lazy query instead of iterating through a…
Browse files Browse the repository at this point in the history
…ll messages
  • Loading branch information
PhilippeWeidmann committed Apr 29, 2024
1 parent 9057a20 commit 43ccd6b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Mail/Components/ThreadCell/ThreadCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ struct ThreadCellDataHolder {
let isInWrittenByMeFolder: Bool

init(thread: Thread) {
let lastMessageNotFromSent = thread.messages.last { $0.folder?.role != .sent } ?? thread.messages.last
let lastMessageNotFromSent = thread.messages.filter(NSPredicate(
format: "SUBQUERY(folders, $folder, $folder.role != %@).@count > 0",
FolderRole.sent.rawValue
)).last ?? thread.messages.last

date = thread.date.formatted(.thread(.list))

subject = thread.formattedSubject
Expand Down

0 comments on commit 43ccd6b

Please sign in to comment.