Clean up licensed user form

This commit is contained in:
Garth Vander Houwen 2023-10-23 17:29:27 -07:00
parent bba379e426
commit 966acb4d7e
2 changed files with 4 additions and 2 deletions

View file

@ -265,6 +265,7 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje
newUser.longName = nodeInfo.user.longName
newUser.shortName = nodeInfo.user.shortName
newUser.hwModel = String(describing: nodeInfo.user.hwModel).uppercased()
newUser.isLicensed = nodeInfo.user.isLicensed
newNode.user = newUser
} else {
let newUser = UserEntity(context: context)
@ -333,6 +334,7 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje
fetchedNode[0].user!.num = Int64(nodeInfo.num)
fetchedNode[0].user!.longName = nodeInfo.user.longName
fetchedNode[0].user!.shortName = nodeInfo.user.shortName
fetchedNode[0].user!.isLicensed = nodeInfo.user.isLicensed
fetchedNode[0].user!.hwModel = String(describing: nodeInfo.user.hwModel).uppercased()
} else {
if (fetchedNode[0].user == nil) {

View file

@ -48,8 +48,8 @@ struct UserConfig: View {
.onChange(of: longName, perform: { _ in
let totalBytes = longName.utf8.count
// Only mess with the value if it is too big
if totalBytes > (isLicensed ? 8 : 36) {
let firstNBytes = Data(longName.utf8.prefix(isLicensed ? 8 : 36))
if totalBytes > (isLicensed ? 6 : 36) {
let firstNBytes = Data(longName.utf8.prefix(isLicensed ? 6 : 36))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the longName back to the last place where it was the right size
longName = maxBytesString