add attachmentCount to ThreadSummary, paperclip badges in thread and item lists

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-15 11:38:29 +01:00
parent 016c163b75
commit d5eaf35665
3 changed files with 28 additions and 8 deletions

View File

@@ -305,6 +305,11 @@ struct ItemRow: View {
.lineLimit(1)
}
}
if msg.hasAttachments {
Image(systemName: "paperclip")
.font(.caption2)
.foregroundStyle(.secondary)
}
case .task(let task):
Image(systemName: task.status == .completed ? "checkmark.circle.fill" :
@@ -368,13 +373,23 @@ struct ThreadRow: View {
.foregroundStyle(.tertiary)
.lineLimit(1)
}
if thread.messageCount > 1 {
Text("\(thread.messageCount)")
HStack(spacing: 6) {
if thread.messageCount > 1 {
Text("\(thread.messageCount)")
.font(.caption2)
.foregroundStyle(.secondary)
.padding(.horizontal, 6)
.padding(.vertical, 1)
.background(.quaternary, in: Capsule())
}
if thread.attachmentCount > 0 {
HStack(spacing: 2) {
Image(systemName: "paperclip")
Text("\(thread.attachmentCount)")
}
.font(.caption2)
.foregroundStyle(.secondary)
.padding(.horizontal, 6)
.padding(.vertical, 1)
.background(.quaternary, in: Capsule())
}
}
}
.padding(.vertical, 2)

View File

@@ -50,7 +50,8 @@ extension MailStore {
t.id, t.accountId, t.subject, t.lastDate, t.messageCount,
(SELECT COUNT(*) FROM threadMessage tm JOIN message m ON m.id = tm.messageId WHERE tm.threadId = t.id AND m.isRead = 0) as unreadCount,
(SELECT GROUP_CONCAT(DISTINCT m.fromName) FROM threadMessage tm JOIN message m ON m.id = tm.messageId WHERE tm.threadId = t.id AND m.fromName IS NOT NULL) as senders,
(SELECT m.snippet FROM threadMessage tm JOIN message m ON m.id = tm.messageId WHERE tm.threadId = t.id ORDER BY m.date DESC LIMIT 1) as snippet
(SELECT m.snippet FROM threadMessage tm JOIN message m ON m.id = tm.messageId WHERE tm.threadId = t.id ORDER BY m.date DESC LIMIT 1) as snippet,
(SELECT COUNT(*) FROM attachment a JOIN threadMessage tm ON tm.messageId = a.messageId WHERE tm.threadId = t.id) as attachmentCount
FROM thread t
WHERE t.accountId = ?
ORDER BY t.lastDate DESC
@@ -65,7 +66,8 @@ extension MailStore {
messageCount: row["messageCount"],
unreadCount: row["unreadCount"],
senders: row["senders"] ?? "",
snippet: row["snippet"]
snippet: row["snippet"],
attachmentCount: row["attachmentCount"]
)
}
}

View File

@@ -9,10 +9,12 @@ public struct ThreadSummary: Sendable, Identifiable, Equatable {
public var unreadCount: Int
public var senders: String
public var snippet: String?
public var attachmentCount: Int
public init(
id: String, accountId: String, subject: String?, lastDate: Date,
messageCount: Int, unreadCount: Int, senders: String, snippet: String?
messageCount: Int, unreadCount: Int, senders: String, snippet: String?,
attachmentCount: Int = 0
) {
self.id = id
self.accountId = accountId
@@ -22,5 +24,6 @@ public struct ThreadSummary: Sendable, Identifiable, Equatable {
self.unreadCount = unreadCount
self.senders = senders
self.snippet = snippet
self.attachmentCount = attachmentCount
}
}