mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix date regressions from #1089
This commit is contained in:
parent
ff58721d73
commit
a550e6b6d9
4 changed files with 15 additions and 9 deletions
|
|
@ -22204,6 +22204,7 @@
|
|||
}
|
||||
},
|
||||
"OTA Updates are not supported on the this NRF Device." : {
|
||||
"extractionState" : "stale",
|
||||
"localizations" : {
|
||||
"sr" : {
|
||||
"stringUnit" : {
|
||||
|
|
@ -22218,6 +22219,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"OTA Updates are not supported on this NRF Device." : {
|
||||
|
||||
},
|
||||
"OTA Updates are not supported on your platform." : {
|
||||
"localizations" : {
|
||||
|
|
|
|||
|
|
@ -10,17 +10,17 @@ import Foundation
|
|||
extension Date {
|
||||
|
||||
var lastHeard: String {
|
||||
if timeIntervalSince1970 > 0 {
|
||||
if self.timeIntervalSince1970 > 0 && self < Calendar.current.date(byAdding: .day, value: 1, to: Date())! {
|
||||
formatted()
|
||||
} else {
|
||||
"unknown"
|
||||
"unknown.age".localized
|
||||
}
|
||||
}
|
||||
|
||||
func formattedDate(format: String) -> String {
|
||||
let dateformat = DateFormatter()
|
||||
dateformat.dateFormat = format
|
||||
if self > Calendar.current.date(byAdding: .year, value: -5, to: Date())! {
|
||||
if self.timeIntervalSince1970 > 0 && self < Calendar.current.date(byAdding: .day, value: 1, to: Date())! {
|
||||
return dateformat.string(from: self)
|
||||
} else {
|
||||
return "unknown.age".localized
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ struct NodeDetail: View {
|
|||
}
|
||||
}
|
||||
|
||||
if let firstHeard = node.firstHeard, firstHeard.timeIntervalSince1970 > 0 {
|
||||
if let firstHeard = node.firstHeard, firstHeard.timeIntervalSince1970 > 0 && firstHeard < Calendar.current.date(byAdding: .year, value: 1, to: Date())! {
|
||||
HStack {
|
||||
Label {
|
||||
Text("First heard")
|
||||
|
|
@ -184,7 +184,7 @@ struct NodeDetail: View {
|
|||
}
|
||||
}
|
||||
|
||||
if let lastHeard = node.lastHeard, lastHeard.timeIntervalSince1970 > 0 {
|
||||
if let lastHeard = node.lastHeard, lastHeard.timeIntervalSince1970 > 0 && lastHeard < Calendar.current.date(byAdding: .year, value: 1, to: Date())! {
|
||||
HStack {
|
||||
Label {
|
||||
Text("Last heard")
|
||||
|
|
@ -195,8 +195,10 @@ struct NodeDetail: View {
|
|||
Spacer()
|
||||
|
||||
if dateFormatRelative, let text = Self.relativeFormatter.string(for: lastHeard) {
|
||||
Text(text)
|
||||
.textSelection(.enabled)
|
||||
if lastHeard.formatted() != "unknown.age".localized {
|
||||
Text(text)
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
} else {
|
||||
Text(lastHeard.formatted())
|
||||
.textSelection(.enabled)
|
||||
|
|
|
|||
|
|
@ -77,10 +77,10 @@ struct NodeListItem: View {
|
|||
imageColor: .green,
|
||||
text: "connected".localized)
|
||||
}
|
||||
if node.lastHeard?.timeIntervalSince1970 ?? 0 > 0 {
|
||||
if node.lastHeard?.timeIntervalSince1970 ?? 0 > 0 && node.lastHeard! < Calendar.current.date(byAdding: .year, value: 1, to: Date())!{
|
||||
IconAndText(systemName: node.isOnline ? "checkmark.circle.fill" : "moon.circle.fill",
|
||||
imageColor: node.isOnline ? .green : .orange,
|
||||
text: node.lastHeard?.formatted() ?? "unknown")
|
||||
text: node.lastHeard?.formatted() ?? "unknown.age".localized)
|
||||
}
|
||||
let role = DeviceRoles(rawValue: Int(node.user?.role ?? 0))
|
||||
IconAndText(systemName: role?.systemName ?? "figure",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue