mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Merge pull request #779 from meshtastic/fix-last-heard-list
revert the last heard text changes on the list view, since that impacts performace
This commit is contained in:
commit
0dc5f5574a
2 changed files with 26 additions and 13 deletions
|
|
@ -8,15 +8,9 @@ import SwiftUI
|
|||
struct LastHeardText: View {
|
||||
var lastHeard: Date?
|
||||
|
||||
static let formatter: RelativeDateTimeFormatter = {
|
||||
let formatter = RelativeDateTimeFormatter()
|
||||
formatter.unitsStyle = .full
|
||||
return formatter
|
||||
}()
|
||||
|
||||
var body: some View {
|
||||
if let lastHeard, lastHeard.timeIntervalSince1970 > 0, let text = Self.formatter.string(for: lastHeard) {
|
||||
Text(text)
|
||||
if let lastHeard, lastHeard.timeIntervalSince1970 > 0 {
|
||||
Text(lastHeard.formatted())
|
||||
} else {
|
||||
Text("unknown")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,17 @@ import CoreLocation
|
|||
import OSLog
|
||||
|
||||
struct NodeDetail: View {
|
||||
private static let relativeFormatter: RelativeDateTimeFormatter = {
|
||||
let formatter = RelativeDateTimeFormatter()
|
||||
formatter.unitsStyle = .full
|
||||
return formatter
|
||||
}()
|
||||
|
||||
@Environment(\.managedObjectContext) var context
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
@State private var showingShutdownConfirm: Bool = false
|
||||
@State private var showingRebootConfirm: Bool = false
|
||||
@State private var dateFormatRelative: Bool = true
|
||||
|
||||
// The node the device is currently connected to
|
||||
var connectedNode: NodeInfoEntity?
|
||||
|
|
@ -138,9 +144,15 @@ struct NodeDetail: View {
|
|||
.symbolRenderingMode(.multicolor)
|
||||
}
|
||||
Spacer()
|
||||
|
||||
LastHeardText(lastHeard: firstHeard)
|
||||
.textSelection(.enabled)
|
||||
if dateFormatRelative, let text = Self.relativeFormatter.string(for: firstHeard) {
|
||||
Text(text)
|
||||
.textSelection(.enabled)
|
||||
} else {
|
||||
Text(firstHeard.formatted())
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
}.onTapGesture {
|
||||
dateFormatRelative.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -154,8 +166,15 @@ struct NodeDetail: View {
|
|||
}
|
||||
Spacer()
|
||||
|
||||
LastHeardText(lastHeard: lastHeard)
|
||||
.textSelection(.enabled)
|
||||
if dateFormatRelative, let text = Self.relativeFormatter.string(for: lastHeard) {
|
||||
Text(text)
|
||||
.textSelection(.enabled)
|
||||
} else {
|
||||
Text(lastHeard.formatted())
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
}.onTapGesture {
|
||||
dateFormatRelative.toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue