mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Button to request updated device metadata for admin channels
This commit is contained in:
parent
70d89c093b
commit
59b9fa9581
7 changed files with 29 additions and 9 deletions
|
|
@ -17,4 +17,8 @@ extension MyInfoEntity {
|
|||
let unreadMessages = messageList.filter{ ($0 as AnyObject).read == false && ($0 as AnyObject).isEmoji == false }
|
||||
return unreadMessages.count
|
||||
}
|
||||
var hasAdmin: Bool {
|
||||
let adminChannel = channels?.filter{ ($0 as AnyObject).name?.lowercased() == "admin" }
|
||||
return adminChannel?.count ?? 0 > 0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ extension NodeInfoEntity {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public func createNodeInfo(num: Int64, context: NSManagedObjectContext) -> NodeInfoEntity {
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ func deviceMetadataPacket (metadata: DeviceMetadata, fromNum: Int64, context: NS
|
|||
return
|
||||
}
|
||||
let newMetadata = DeviceMetadataEntity(context: context)
|
||||
newMetadata.time = Date()
|
||||
newMetadata.deviceStateVersion = Int32(metadata.deviceStateVersion)
|
||||
newMetadata.canShutdown = metadata.canShutdown
|
||||
newMetadata.hasWifi = metadata.hasWifi_p
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@
|
|||
<attribute name="hwModel" optional="YES" attributeType="String"/>
|
||||
<attribute name="positionFlags" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="role" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="time" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||
<relationship name="metadataNode" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="NodeInfoEntity" inverseName="metadata" inverseEntity="NodeInfoEntity"/>
|
||||
</entity>
|
||||
<entity name="DisplayConfigEntity" representedClassName="DisplayConfigEntity" syncable="YES" codeGenerationType="class">
|
||||
|
|
|
|||
|
|
@ -26,6 +26,27 @@ struct NodeDetail: View {
|
|||
VStack {
|
||||
ScrollView {
|
||||
NodeInfoItem(node: node)
|
||||
if node.metadata != nil {
|
||||
HStack(alignment: .center) {
|
||||
Text("firmware.version").font(.title2)+Text(": \(node.metadata?.firmwareVersion ?? "unknown".localized)")
|
||||
.font(.title3).foregroundColor(Color.gray)
|
||||
if connectedNode != nil && connectedNode?.myInfo?.hasAdmin ?? false && node.metadata?.time != nil && !Calendar.current.isDateInToday(node.metadata!.time!) {
|
||||
Button {
|
||||
let adminMessageId = bleManager.requestDeviceMetadata(fromUser: connectedNode!.user!, toUser: node.user!, adminIndex: connectedNode!.myInfo!.adminIndex, context: context)
|
||||
if adminMessageId > 0 {
|
||||
print("Sent node metadata request from node details")
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "arrow.clockwise")
|
||||
.font(.title3)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.buttonBorderShape(.capsule)
|
||||
.controlSize(.small)
|
||||
}
|
||||
}
|
||||
Divider()
|
||||
}
|
||||
VStack {
|
||||
NavigationLink {
|
||||
DeviceMetricsLog(node: node)
|
||||
|
|
|
|||
|
|
@ -79,12 +79,5 @@ struct NodeInfoItem: View {
|
|||
}
|
||||
}
|
||||
Divider()
|
||||
if node.metadata != nil {
|
||||
HStack(alignment: .center) {
|
||||
Text("firmware.version").font(.title2)+Text(": \(node.metadata?.firmwareVersion ?? "unknown".localized)")
|
||||
.font(.title3).foregroundColor(Color.gray)
|
||||
}
|
||||
Divider()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,7 +175,8 @@ struct RouteRecorder: View {
|
|||
locationsHandler.recordingStarted = Date()
|
||||
let newRoute = RouteEntity(context: context)
|
||||
newRoute.date = Date()
|
||||
newRoute.name = "\(newRoute.date?.relativeTimeOfDay() ?? "morning".localized) hike"
|
||||
let at = ActivityType(rawValue: activity)
|
||||
newRoute.name = "\(newRoute.date?.relativeTimeOfDay() ?? "morning".localized) \(at?.fileNameString ?? "hike")"
|
||||
newRoute.id = Int32.random(in: Int32(Int8.max) ... Int32.max)
|
||||
newRoute.color = Int64(UIColor.random.hex)
|
||||
newRoute.enabled = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue