@@ -1104,11 +1104,11 @@ export default class SyncProcess {
11041104 ) : Diff < L1 , TItemLocation , ReorderAction < L1 , TItemLocation > > {
11051105 Logger . log ( 'Reconciling reorders to create a plan' )
11061106
1107- const sourceCreations = targetDonePlan . CREATE . getActions ( )
1108- const sourceRemovals = targetDonePlan . REMOVE . getActions ( )
1109- const sourceMoves = targetDonePlan . MOVE . getActions ( )
1110- const sourceCreationsAndMoves : Action < TItemLocation , TItemLocation > [ ] = ( sourceCreations as Action < TItemLocation , TItemLocation > [ ] ) . concat ( sourceMoves )
1111- const sourceTree = targetLocation === ItemLocation . LOCAL ? this . localTreeRoot : this . serverTreeRoot
1107+ const targetCreations = targetDonePlan . CREATE . getActions ( )
1108+ const targetRemovals = targetDonePlan . REMOVE . getActions ( )
1109+ const targetMoves = targetDonePlan . MOVE . getActions ( )
1110+ const targetCreationsAndMoves : Action < TItemLocation , TItemLocation > [ ] = ( targetCreations as Action < TItemLocation , TItemLocation > [ ] ) . concat ( targetMoves )
1111+ const targetTree = targetLocation === ItemLocation . LOCAL ? this . localTreeRoot : this . serverTreeRoot
11121112
11131113 const newReorders = new Diff < L2 , TItemLocation , ReorderAction < L2 , TItemLocation > >
11141114
@@ -1120,23 +1120,23 @@ export default class SyncProcess {
11201120 // clone action
11211121 const reorderAction = { ...oldReorderAction , order : oldReorderAction . order . slice ( ) }
11221122
1123- const removed = sourceRemovals
1123+ const removed = targetRemovals
11241124 . filter ( removal =>
1125- Diff . findChain ( mappingSnapshot , sourceCreationsAndMoves , sourceTree , oldReorderAction . payload , removal ) )
1125+ Diff . findChain ( mappingSnapshot , targetCreationsAndMoves , targetTree , oldReorderAction . payload , removal ) )
11261126 if ( removed . length ) {
11271127 return
11281128 }
11291129
11301130 // Find Away-moves
1131- const childAwayMoves = sourceMoves
1131+ const childAwayMoves = targetMoves
11321132 . filter ( move =>
11331133 Mappings . mapId ( mappingSnapshot , reorderAction . payload , move . payload . location ) !== String ( move . payload . parentId ) &&
11341134 reorderAction . order . find ( item =>
11351135 Mappings . mapRawId ( mappingSnapshot , item . id , item . type , reorderAction . payload . location , move . payload . location ) === String ( move . payload . id ) && item . type === move . payload . type )
11361136 )
11371137
11381138 // Find removals
1139- const concurrentRemovals = sourceRemovals
1139+ const concurrentRemovals = targetRemovals
11401140 . filter ( removal =>
11411141 reorderAction . order . find ( item =>
11421142 Mappings . mapRawId ( mappingSnapshot , item . id , item . type , reorderAction . payload . location , removal . payload . location ) === String ( removal . payload . id ) && item . type === removal . payload . type ) )
@@ -1164,7 +1164,7 @@ export default class SyncProcess {
11641164 } )
11651165
11661166 // Find and insert creations
1167- const concurrentCreations = sourceCreations
1167+ const concurrentCreations = targetCreations
11681168 . filter ( creation => String ( reorderAction . payload . id ) === String ( creation . payload . parentId ) )
11691169 concurrentCreations
11701170 . forEach ( a => {
@@ -1173,7 +1173,7 @@ export default class SyncProcess {
11731173 } )
11741174
11751175 // Find and insert moves at move target
1176- const moves = sourceMoves
1176+ const moves = targetMoves
11771177 . filter ( move =>
11781178 String ( reorderAction . payload . id ) === String ( move . payload . parentId ) &&
11791179 ! reorderAction . order . find ( item => String ( item . id ) === String ( move . payload . id ) && item . type === move . payload . type )
0 commit comments