mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Delete nodes on that channel when deleting a channel
This commit is contained in:
parent
95109a3d9d
commit
7cdf77ba2e
1 changed files with 14 additions and 1 deletions
|
|
@ -47,6 +47,14 @@ struct Channels: View {
|
|||
|
||||
/// Minimum Version for granular position configuration
|
||||
@State var minimumVersion = "2.2.24"
|
||||
|
||||
@FetchRequest(
|
||||
sortDescriptors: [NSSortDescriptor(key: "favorite", ascending: false),
|
||||
NSSortDescriptor(key: "lastHeard", ascending: false),
|
||||
NSSortDescriptor(key: "user.longName", ascending: true)],
|
||||
animation: .default)
|
||||
|
||||
var nodes: FetchedResults<NodeInfoEntity>
|
||||
|
||||
var body: some View {
|
||||
|
||||
|
|
@ -182,10 +190,16 @@ struct Channels: View {
|
|||
guard let channelEntity = node?.myInfo?.channels?.first(where: { ($0 as! ChannelEntity).index == channelIndex }) else {
|
||||
return
|
||||
}
|
||||
|
||||
let objects = (channelEntity as! ChannelEntity).allPrivateMessages
|
||||
for object in objects {
|
||||
context.delete(object)
|
||||
}
|
||||
for node in nodes {
|
||||
if node.channel == (channelEntity as AnyObject).index {
|
||||
context.delete(node)
|
||||
}
|
||||
}
|
||||
context.delete(channelEntity as! ChannelEntity)
|
||||
do {
|
||||
try context.save()
|
||||
|
|
@ -288,7 +302,6 @@ func firstMissingChannelIndex(_ indexes: [Int]) -> Int {
|
|||
return indexes.count + 1
|
||||
}
|
||||
|
||||
|
||||
enum PositionPrecision: Int, CaseIterable, Identifiable {
|
||||
|
||||
case eleven = 11
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue