@@ -415,10 +415,12 @@ final class WelcomeViewModel {
415415
416416 func moveConnections( _ targets: [ DatabaseConnection ] , toGroup groupId: UUID ) {
417417 let ids = Set ( targets. map ( \. id) )
418+ var updated : [ DatabaseConnection ] = [ ]
418419 for i in connections. indices where ids. contains ( connections [ i] . id) {
419420 connections [ i] . groupId = groupId
421+ updated. append ( connections [ i] )
420422 }
421- guard storage. saveConnections ( connections ) else {
423+ guard storage. updateConnections ( updated ) else {
422424 connections = storage. loadConnections ( )
423425 rebuildTree ( )
424426 return
@@ -428,10 +430,12 @@ final class WelcomeViewModel {
428430
429431 func removeFromGroup( _ targets: [ DatabaseConnection ] ) {
430432 let ids = Set ( targets. map ( \. id) )
433+ var updated : [ DatabaseConnection ] = [ ]
431434 for i in connections. indices where ids. contains ( connections [ i] . id) {
432435 connections [ i] . groupId = nil
436+ updated. append ( connections [ i] )
433437 }
434- guard storage. saveConnections ( connections ) else {
438+ guard storage. updateConnections ( updated ) else {
435439 connections = storage. loadConnections ( )
436440 rebuildTree ( )
437441 return
@@ -549,26 +553,23 @@ final class WelcomeViewModel {
549553
550554 let updatedValidGroupIds = Set ( groups. map ( \. id) )
551555 var order = 0
552- var dirtyIds : [ String ] = [ ]
556+ var updated : [ DatabaseConnection ] = [ ]
553557 for i in connections. indices {
554558 let isUngrouped = connections [ i] . groupId. map { !updatedValidGroupIds. contains ( $0) } ?? true
555559 if isUngrouped {
556560 if connections [ i] . sortOrder != order {
557561 connections [ i] . sortOrder = order
558- dirtyIds . append ( connections [ i] . id . uuidString )
562+ updated . append ( connections [ i] )
559563 }
560564 order += 1
561565 }
562566 }
563567
564- guard storage. saveConnections ( connections ) else {
568+ guard storage. updateConnections ( updated ) else {
565569 connections = storage. loadConnections ( )
566570 rebuildTree ( )
567571 return
568572 }
569- if !dirtyIds. isEmpty {
570- services. syncTracker. markDirty ( . connection, ids: dirtyIds)
571- }
572573 rebuildTree ( )
573574 }
574575
@@ -591,23 +592,20 @@ final class WelcomeViewModel {
591592 connections. move ( fromOffsets: globalSource, toOffset: globalDestination)
592593
593594 var order = 0
594- var dirtyIds : [ String ] = [ ]
595+ var updated : [ DatabaseConnection ] = [ ]
595596 for i in connections. indices where connections [ i] . groupId == group. id {
596597 if connections [ i] . sortOrder != order {
597598 connections [ i] . sortOrder = order
598- dirtyIds . append ( connections [ i] . id . uuidString )
599+ updated . append ( connections [ i] )
599600 }
600601 order += 1
601602 }
602603
603- guard storage. saveConnections ( connections ) else {
604+ guard storage. updateConnections ( updated ) else {
604605 connections = storage. loadConnections ( )
605606 rebuildTree ( )
606607 return
607608 }
608- if !dirtyIds. isEmpty {
609- services. syncTracker. markDirty ( . connection, ids: dirtyIds)
610- }
611609 rebuildTree ( )
612610 }
613611
0 commit comments