V 1.43 Build 2 - Complete DM feature. Save the broadcast users if it does not exist when saving a myInfo

This commit is contained in:
Garth Vander Houwen 2022-01-01 19:08:36 -08:00
parent e4e4e381a9
commit e17091ff4f
4 changed files with 48 additions and 10 deletions

View file

@ -718,6 +718,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\"";
DEVELOPMENT_TEAM = GCH7VS5Y9R;
ENABLE_PREVIEWS = YES;
@ -727,7 +728,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.42;
MARKETING_VERSION = 1.43;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
@ -745,6 +746,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\"";
DEVELOPMENT_TEAM = GCH7VS5Y9R;
ENABLE_PREVIEWS = YES;
@ -754,7 +756,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.42;
MARKETING_VERSION = 1.43;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;

View file

@ -425,7 +425,29 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
myInfo.maxChannels = Int32(bitPattern: decodedInfo.myInfo.maxChannels)
connectedPeripheral.num = myInfo.myNodeNum
connectedPeripheral.firmwareVersion = myInfo.firmwareVersion ?? "Unknown"
let fetchBCUserRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "UserEntity")
fetchBCUserRequest.predicate = NSPredicate(format: "num == %lld", Int64(decodedInfo.myInfo.myNodeNum))
do {
let fetchedUser = try context?.fetch(fetchBCUserRequest) as! [UserEntity]
if fetchedUser.isEmpty {
// Save the broadcast user if it does not exist
let bcu: UserEntity = UserEntity(context: context!)
bcu.shortName = "ALL"
bcu.longName = "All - Broadcast"
bcu.hwModel = "UNSET"
bcu.num = Int64(broadcastNodeNum)
bcu.userId = "BROADCASTNODE"
print("💾 Saved the All - Broadcast User")
}
} catch {
print("💥 Error Saving the All - Broadcast User")
}
} else {
fetchedMyInfo[0].myNodeNum = Int64(decodedInfo.myInfo.myNodeNum)

View file

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>

View file

@ -28,18 +28,17 @@ struct UserMessageList: View {
@State var showDeleteMessageAlert = false
@State private var deleteMessageId: Int64 = 0
@State var mergedMessageList: NSMutableOrderedSet?
@State var messageCount = 0
var body: some View {
VStack {
let allMessages = user.value(forKey: "allMessages") as! [MessageEntity]
ScrollViewReader { scrollView in
ScrollView {
// Use fetched property
let allMessages = user.value(forKey: "allMessages")
as! [MessageEntity]
if allMessages.count > 0 {
@ -106,10 +105,25 @@ struct UserMessageList: View {
.onAppear(perform: {
self.bleManager.context = context
if mergedMessageList?.count ?? 0 > 0 {
scrollView.scrollTo((mergedMessageList![mergedMessageList!.count-1] as AnyObject).id, anchor: .bottom)
messageCount = ((user.sentMessages?.count ?? 0) + (user.receivedMessages?.count ?? 0))
if messageCount > 0 {
//scrollView.scrollTo(allMessages[allMessages.count-1].id, anchor: .bottom)
//scrollView.scrollTo(allMessages[allMessages.endIndex - 1])
//scrollView.scrollTo((allMessages[messageCount-1] as AnyObject).id, anchor: .bottom)
}
})
.onChange(of: user, perform: { newValue in
messageCount = ((user.sentMessages?.count ?? 0) + (user.receivedMessages?.count ?? 0))
if messageCount > 0 {
//scrollView.scrollTo((allMessages[messageCount-1] as AnyObject).id, anchor: .bottom)
}
}
)
}