De-duplicate logic for log colors.

This commit is contained in:
Brent Simmons committed 2026-06-06 10:32:01 -07:00
1 parent d89f85a23c
commit 1e7bf4048d
2 files changed
+24 -28

No files matched your search

+23
View File
@@ -68,6 +68,29 @@ extension AccountType {
return .systemPink
}
}
#else
var logColor: Color {
switch self {
case .onMyMac:
return .secondary
case .cloudKit:
return .purple
case .feedly:
return .green
case .feedbin:
return .blue
case .newsBlur:
return .orange
case .freshRSS:
return .teal
case .inoreader:
return .brown
case .bazQux:
return .indigo
case .theOldReader:
return .pink
}
}
#endif
// MARK: - SwiftUI Images
+1 -28
View File
@@ -97,7 +97,7 @@ private extension ErrorLogView {
sourceString = "\(entry.sourceName) — \(entry.operation): "
}
var source = AttributedString(sourceString)
source.foregroundColor = color(for: entry.sourceID)
source.foregroundColor = AccountType(rawValue: entry.sourceID)?.logColor ?? .secondary
source.font = .system(.body, design: .monospaced).weight(.medium)
var message = AttributedString(entry.errorMessage)
@@ -135,33 +135,6 @@ private extension ErrorLogView {
return result
}
func color(for sourceID: Int) -> Color {
guard let type = AccountType(rawValue: sourceID) else {
return .secondary
}
switch type {
case .onMyMac:
return .secondary
case .cloudKit:
return .purple
case .feedly:
return .green
case .feedbin:
return .blue
case .newsBlur:
return .orange
case .freshRSS:
return .teal
case .inoreader:
return .brown
case .bazQux:
return .indigo
case .theOldReader:
return .pink
}
}
func errorLogEntry(from notification: Notification) -> ErrorLogEntry? {
guard let errorMessage = notification.userInfo?[ErrorLogUserInfoKey.errorMessage] as? String,
let sourceName = notification.userInfo?[ErrorLogUserInfoKey.sourceName] as? String,