@@ -11,13 +11,8 @@ import { deepEquals } from "../utils"
11
11
import type { StandardSchemaV1 } from "@standard-schema/spec"
12
12
import type {
13
13
ChangeMessage ,
14
- < << << << HEAD
15
14
CleanupFn ,
16
15
CollectionConfig ,
17
- = === ===
18
- CollectionConfig ,
19
- CleanupFn ,
20
- > >>> >>> 684 c70ec ( Add onLoadMore callback and call it from the requestSnapshot methods )
21
16
OnLoadMoreOptions ,
22
17
SyncConfigRes ,
23
18
} from "../types"
@@ -99,7 +94,6 @@ export class CollectionSyncManager<
99
94
}
100
95
const key = this . config . getKey ( messageWithoutKey . value )
101
96
102
- << < < < << HEAD
103
97
let messageType = messageWithoutKey . type
104
98
105
99
// Check if an item with this key already exists when inserting
@@ -177,71 +171,6 @@ export class CollectionSyncManager<
177
171
throw new SyncTransactionAlreadyCommittedWriteError ( )
178
172
}
179
173
180
- = === ===
181
- // Check if an item with this key already exists when inserting
182
- if ( messageWithoutKey . type === `insert` ) {
183
- const insertingIntoExistingSynced = this . state . syncedData . has ( key )
184
- const hasPendingDeleteForKey =
185
- pendingTransaction . deletedKeys . has ( key )
186
- const isTruncateTransaction = pendingTransaction . truncate === true
187
- // Allow insert after truncate in the same transaction even if it existed in syncedData
188
- if (
189
- insertingIntoExistingSynced &&
190
- ! hasPendingDeleteForKey &&
191
- ! isTruncateTransaction
192
- ) {
193
- throw new DuplicateKeySyncError ( key , this . id )
194
- }
195
- }
196
-
197
- const message : ChangeMessage < TOutput > = {
198
- ...messageWithoutKey ,
199
- key,
200
- }
201
- pendingTransaction . operations . push ( message )
202
-
203
- if ( messageWithoutKey . type === `delete` ) {
204
- pendingTransaction . deletedKeys . add ( key )
205
- }
206
- } ,
207
- commit : ( ) => {
208
- const pendingTransaction =
209
- this . state . pendingSyncedTransactions [
210
- this . state . pendingSyncedTransactions . length - 1
211
- ]
212
- if ( ! pendingTransaction ) {
213
- throw new NoPendingSyncTransactionCommitError ( )
214
- }
215
- if ( pendingTransaction . committed ) {
216
- throw new SyncTransactionAlreadyCommittedError ( )
217
- }
218
-
219
- pendingTransaction . committed = true
220
-
221
- // Update status to initialCommit when transitioning from loading
222
- // This indicates we're in the process of committing the first transaction
223
- if ( this . lifecycle . status === `loading` ) {
224
- this . lifecycle . setStatus ( `initialCommit` )
225
- }
226
-
227
- this . state . commitPendingTransactions ( )
228
- } ,
229
- markReady : ( ) => {
230
- this . lifecycle . markReady ( )
231
- } ,
232
- truncate : ( ) => {
233
- const pendingTransaction =
234
- this . state . pendingSyncedTransactions [
235
- this . state . pendingSyncedTransactions . length - 1
236
- ]
237
- if ( ! pendingTransaction ) {
238
- throw new NoPendingSyncTransactionWriteError ( )
239
- }
240
- if ( pendingTransaction . committed ) {
241
- throw new SyncTransactionAlreadyCommittedWriteError ( )
242
- }
243
-
244
- > >>> >>> 684 c70ec ( Add onLoadMore callback and call it from the requestSnapshot methods )
245
174
// Clear all operations from the current transaction
246
175
pendingTransaction . operations = [ ]
247
176
pendingTransaction . deletedKeys . clear ( )
0 commit comments