mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Display name updates
This commit is contained in:
parent
204b2ebb32
commit
894bd6673c
3 changed files with 8 additions and 27 deletions
|
|
@ -288,6 +288,12 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje
|
|||
newUser.shortName = nodeInfo.user.shortName
|
||||
newUser.hwModel = String(describing: nodeInfo.user.hwModel).uppercased()
|
||||
newUser.hwModelId = Int32(nodeInfo.user.hwModel.rawValue)
|
||||
Task {
|
||||
Api().loadDeviceHardwareData { (hw) in
|
||||
let dh = hw.first(where: { $0.hwModel == newUser.hwModelId })
|
||||
newUser.hwDisplayName = dh?.displayName
|
||||
}
|
||||
}
|
||||
newUser.isLicensed = nodeInfo.user.isLicensed
|
||||
newUser.role = Int32(nodeInfo.user.role.rawValue)
|
||||
newNode.user = newUser
|
||||
|
|
|
|||
|
|
@ -414,6 +414,7 @@
|
|||
<relationship name="traceRoute" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="TraceRouteEntity" inverseName="hops" inverseEntity="TraceRouteEntity"/>
|
||||
</entity>
|
||||
<entity name="UserEntity" representedClassName="UserEntity" syncable="YES" codeGenerationType="class">
|
||||
<attribute name="hwDisplayName" optional="YES" attributeType="String"/>
|
||||
<attribute name="hwModel" attributeType="String"/>
|
||||
<attribute name="hwModelId" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="isLicensed" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ import MapKit
|
|||
struct NodeInfoItem: View {
|
||||
|
||||
@ObservedObject var node: NodeInfoEntity
|
||||
@State private var currentDevice: DeviceHardware?
|
||||
@State private var deviceHardware: [DeviceHardware] = []
|
||||
|
||||
var modemPreset: ModemPresets = ModemPresets(
|
||||
rawValue: UserDefaults.modemPreset
|
||||
|
|
@ -30,7 +28,7 @@ struct NodeInfoItem: View {
|
|||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 65, height: 65)
|
||||
.cornerRadius(5)
|
||||
Text(String(currentDevice?.displayName ?? (node.user?.hwModel ?? "unset".localized)))
|
||||
Text(String(node.user?.hwDisplayName ?? (node.user?.hwModel ?? "unset".localized)))
|
||||
.font(.callout)
|
||||
} else {
|
||||
Image(systemName: "person.crop.circle.badge.questionmark")
|
||||
|
|
@ -42,30 +40,6 @@ struct NodeInfoItem: View {
|
|||
.font(.callout)
|
||||
}
|
||||
}
|
||||
.onAppear(perform: {
|
||||
if currentDevice == nil {
|
||||
Api().loadDeviceHardwareData { (hw) in
|
||||
for device in hw {
|
||||
let currentHardware = node.user?.hwModel ?? "UNSET"
|
||||
let deviceString = device.hwModelSlug.replacingOccurrences(of: "_", with: "")
|
||||
if deviceString == currentHardware {
|
||||
currentDevice = device
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.onChange(of: node) { newNode in
|
||||
Api().loadDeviceHardwareData { (hw) in
|
||||
for device in hw {
|
||||
let currentHardware = newNode.user?.hwModel ?? "UNSET"
|
||||
let deviceString = device.hwModelSlug.replacingOccurrences(of: "_", with: "")
|
||||
if deviceString == currentHardware {
|
||||
currentDevice = device
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HStack(alignment: .center) {
|
||||
Spacer()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue