mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-03 10:47:21 +00:00
De-duplicate logic for log colors.
This commit is contained in:
1 parent
d89f85a23c
commit
1e7bf4048d
2 files changed
+24
-28
No files matched your search
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user