Skip to content

Commit db02934

Browse files
committed
fix(reconcileReorderings): Fix ID comparisons
make sure to convert to string before comparing Signed-off-by: Marcel Klehr <[email protected]>
1 parent 226b029 commit db02934

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/lib/strategies/Default.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,32 +1136,32 @@ export default class SyncProcess {
11361136
// Find Away-moves
11371137
const childAwayMoves = targetMoves
11381138
.filter(move =>
1139-
Mappings.mapId(mappingSnapshot, reorderAction.payload, move.payload.location) !== String(move.payload.parentId) &&
1139+
String(Mappings.mapId(mappingSnapshot, reorderAction.payload, move.payload.location)) !== String(move.payload.parentId) &&
11401140
reorderAction.order.find(item =>
1141-
Mappings.mapRawId(mappingSnapshot, item.id, item.type, reorderAction.payload.location, move.payload.location) === String(move.payload.id) && item.type === move.payload.type)
1141+
String(Mappings.mapRawId(mappingSnapshot, item.id, item.type, reorderAction.payload.location, move.payload.location)) === String(move.payload.id) && item.type === move.payload.type)
11421142
)
11431143

11441144
// Find removals
11451145
const concurrentRemovals = targetRemovals
11461146
.filter(removal =>
11471147
reorderAction.order.find(item =>
1148-
Mappings.mapRawId(mappingSnapshot, item.id, item.type, reorderAction.payload.location, removal.payload.location) === String(removal.payload.id) && item.type === removal.payload.type))
1148+
String(Mappings.mapRawId(mappingSnapshot, item.id, item.type, reorderAction.payload.location, removal.payload.location)) === String(removal.payload.id) && item.type === removal.payload.type))
11491149

11501150
// Remove away-moves and removals
11511151
reorderAction.order = reorderAction.order.filter(item => {
11521152
let action
11531153
if (
11541154
// eslint-disable-next-line no-cond-assign
11551155
action = childAwayMoves.find(move =>
1156-
Mappings.mapRawId(mappingSnapshot, item.id, item.type, reorderAction.payload.location, move.payload.location) === String(move.payload.id) && move.payload.type === item.type)) {
1156+
String(Mappings.mapRawId(mappingSnapshot, item.id, item.type, reorderAction.payload.location, move.payload.location)) === String(move.payload.id) && move.payload.type === item.type)) {
11571157
Logger.log('ReconcileReorders: Removing moved item from order', {move: action, reorder: reorderAction})
11581158
return false
11591159
}
11601160

11611161
if (
11621162
// eslint-disable-next-line no-cond-assign
11631163
action = concurrentRemovals.find(removal =>
1164-
Mappings.mapRawId(mappingSnapshot, item.id, item.type, reorderAction.payload.location, removal.payload.location) === String(removal.payload.id) && removal.payload.type === item.type)
1164+
String(Mappings.mapRawId(mappingSnapshot, item.id, item.type, reorderAction.payload.location, removal.payload.location)) === String(removal.payload.id) && removal.payload.type === item.type)
11651165
) {
11661166
Logger.log('ReconcileReorders: Removing removed item from order', {item, reorder: reorderAction, removal: action})
11671167
return false
@@ -1351,11 +1351,11 @@ export default class SyncProcess {
13511351
mappingsSnapshot: MappingSnapshot,
13521352
sourceReorders:Diff<TItemLocation, TItemLocation, ReorderAction<TItemLocation, TItemLocation>>,
13531353
oldItem: TItem<TItemLocation>) {
1354-
const parentReorder = sourceReorders.getActions().find(action => Mappings.mapId(mappingsSnapshot, action.payload, oldItem.location) === oldItem.parentId)
1354+
const parentReorder = sourceReorders.getActions().find(action => String(Mappings.mapId(mappingsSnapshot, action.payload, oldItem.location)) === String(oldItem.parentId))
13551355
if (!parentReorder) {
13561356
return
13571357
}
1358-
parentReorder.order = parentReorder.order.filter(item => !(item.type === oldItem.type && Mappings.mapId(mappingsSnapshot, oldItem, parentReorder.payload.location) === item.id))
1358+
parentReorder.order = parentReorder.order.filter(item => !(item.type === oldItem.type && String(Mappings.mapId(mappingsSnapshot, oldItem, parentReorder.payload.location)) === String(item.id)))
13591359
}
13601360

13611361
toJSON(): ISerializedSyncProcess {

0 commit comments

Comments
 (0)