mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix delete a messages from contacts, use getchannel instead of wantConfig after saving a channel
This commit is contained in:
parent
5b56125628
commit
871a5f30ab
3 changed files with 12 additions and 22 deletions
|
|
@ -1026,10 +1026,7 @@ func adminAppPacket (packet: MeshPacket, context: NSManagedObjectContext) {
|
|||
|
||||
else if adminMessage.payloadVariant == AdminMessage.OneOf_PayloadVariant.getChannelResponse(adminMessage.getChannelResponse) {
|
||||
|
||||
if let channel = try? Channel(serializedData: packet.decoded.payload) {
|
||||
print("got a channel over the admin channel")
|
||||
//channelPacket(channel: channel, fromNum: Int64(packet.from), context: context)
|
||||
}
|
||||
channelPacket(channel: adminMessage.getChannelResponse, fromNum: Int64(packet.from), context: context)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ struct Contacts: View {
|
|||
|
||||
private var users: FetchedResults<UserEntity>
|
||||
@State var node: NodeInfoEntity? = nil
|
||||
@State private var selection: UserEntity? = nil // Nothing selected by default.
|
||||
@State private var userSelection: UserEntity? = nil // Nothing selected by default.
|
||||
@State private var channelSelection: ChannelEntity? = nil // Nothing selected by default.
|
||||
@State private var isPresentingDeleteChannelMessagesConfirm: Bool = false
|
||||
@State private var isPresentingDeleteUserMessagesConfirm: Bool = false
|
||||
@State private var isPresentingTraceRouteSentAlert = false
|
||||
|
|
@ -113,6 +114,7 @@ struct Contacts: View {
|
|||
if channel.allPrivateMessages.count > 0 {
|
||||
Button(role: .destructive) {
|
||||
isPresentingDeleteChannelMessagesConfirm = true
|
||||
channelSelection = channel
|
||||
} label: {
|
||||
Label("Delete Messages", systemImage: "trash")
|
||||
}
|
||||
|
|
@ -121,22 +123,12 @@ struct Contacts: View {
|
|||
.confirmationDialog(
|
||||
"This conversation will be deleted.",
|
||||
isPresented: $isPresentingDeleteChannelMessagesConfirm,
|
||||
|
||||
titleVisibility: .visible
|
||||
) {
|
||||
|
||||
Button(role: .destructive) {
|
||||
do {
|
||||
for message in channel.allPrivateMessages {
|
||||
context.delete(message)
|
||||
}
|
||||
try context.save()
|
||||
context.refresh(node!.myInfo!, mergeChanges: true)
|
||||
} catch let error as NSError {
|
||||
print("Error: \(error.localizedDescription)")
|
||||
}
|
||||
//deleteChannelMessages(channel: channel, context: context)
|
||||
|
||||
deleteChannelMessages(channel: channelSelection!, context: context)
|
||||
context.refresh(node!.myInfo!, mergeChanges: true)
|
||||
channelSelection = nil
|
||||
} label: {
|
||||
Text("delete")
|
||||
}
|
||||
|
|
@ -217,6 +209,7 @@ struct Contacts: View {
|
|||
if user.messageList.count > 0 {
|
||||
Button(role: .destructive) {
|
||||
isPresentingDeleteUserMessagesConfirm = true
|
||||
userSelection = user
|
||||
} label: {
|
||||
Label("Delete Messages", systemImage: "trash")
|
||||
}
|
||||
|
|
@ -238,7 +231,7 @@ struct Contacts: View {
|
|||
titleVisibility: .visible
|
||||
) {
|
||||
Button(role: .destructive) {
|
||||
deleteUserMessages(user: user, context: context)
|
||||
deleteUserMessages(user: userSelection!, context: context)
|
||||
context.refresh(node!.user!, mergeChanges: true)
|
||||
} label: {
|
||||
Text("delete")
|
||||
|
|
@ -283,7 +276,7 @@ struct Contacts: View {
|
|||
}
|
||||
}
|
||||
detail: {
|
||||
if let user = selection {
|
||||
if let user = userSelection {
|
||||
UserMessageList(user:user)
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -258,8 +258,8 @@ struct Channels: View {
|
|||
channelName = ""
|
||||
hasChanges = false
|
||||
// Would rather send a getChannel but I can't seem serialize it properly yet
|
||||
//bleManager.getChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!)
|
||||
bleManager.sendWantConfig()
|
||||
bleManager.getChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!)
|
||||
//bleManager.sendWantConfig()
|
||||
}
|
||||
} label: {
|
||||
Label("save", systemImage: "square.and.arrow.down")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue