@@ -94,7 +94,7 @@ export class CollectionSyncManager<
94
94
}
95
95
const key = this . config . getKey ( messageWithoutKey . value )
96
96
97
- let messageType = messageWithoutKey . type
97
+ let messageType = messageWithoutKey . type
98
98
99
99
// Check if an item with this key already exists when inserting
100
100
if ( messageWithoutKey . type === `insert` ) {
@@ -108,25 +108,25 @@ export class CollectionSyncManager<
108
108
! hasPendingDeleteForKey &&
109
109
! isTruncateTransaction
110
110
) {
111
- const existingValue = state . syncedData . get ( key )
112
- if (
113
- existingValue !== undefined &&
114
- deepEquals ( existingValue , messageWithoutKey . value )
115
- ) {
116
- // The "insert" is an echo of a value we already have locally.
117
- // Treat it as an update so we preserve optimistic intent without
118
- // throwing a duplicate-key error during reconciliation.
119
- messageType = `update`
120
- } else {
121
- throw new DuplicateKeySyncError ( key , this . id )
111
+ const existingValue = this . state . syncedData . get ( key )
112
+ if (
113
+ existingValue !== undefined &&
114
+ deepEquals ( existingValue , messageWithoutKey . value )
115
+ ) {
116
+ // The "insert" is an echo of a value we already have locally.
117
+ // Treat it as an update so we preserve optimistic intent without
118
+ // throwing a duplicate-key error during reconciliation.
119
+ messageType = `update`
120
+ } else {
121
+ throw new DuplicateKeySyncError ( key , this . id )
122
122
}
123
- }
123
+ }
124
124
}
125
125
126
126
const message : ChangeMessage < TOutput > = {
127
127
...messageWithoutKey ,
128
128
type : messageType ,
129
- key,
129
+ key,
130
130
}
131
131
pendingTransaction . operations . push ( message )
132
132
0 commit comments