MCPcopy Create free account
hub / github.com/CommE2E/comm / processDBStoreOperations

Function processDBStoreOperations

web/database/sqlite-api.js:244–280  ·  view source on GitHub ↗
(
    storeOperations: StoreOperations,
    dbID: DatabaseIdentifier,
  )

Source from the content-addressed store, hash-verified

242 },
243
244 async processDBStoreOperations(
245 storeOperations: StoreOperations,
246 dbID: DatabaseIdentifier,
247 ): Promise<void> {
248 const dbOps =
249 convertStoreOperationsToClientDBStoreOperations(storeOperations);
250
251 if (!values(dbOps).some(ops => ops && ops.length > 0)) {
252 return;
253 }
254
255 const sharedWorker = await getCommSharedWorker();
256 const isSupported = await sharedWorker.isSupported();
257 if (!isSupported) {
258 return;
259 }
260 try {
261 await sharedWorker.schedule({
262 type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS,
263 storeOperations: dbOps,
264 dbID,
265 });
266 } catch (e) {
267 console.log(e);
268 if (
269 entries(storeOperations).some(
270 ([key, ops]) =>
271 key !== 'draftStoreOperations' &&
272 key !== 'reportStoreOperations' &&
273 ops.length > 0,
274 )
275 ) {
276 await sharedWorker.init({ clearDatabase: true, markAsCorrupted: true });
277 location.reload();
278 }
279 }
280 },
281
282 //backup
283 async restoreUserData(

Callers 2

DBOpsHandlerFunction · 0.50

Calls 8

valuesFunction · 0.90
getCommSharedWorkerFunction · 0.90
entriesFunction · 0.90
isSupportedMethod · 0.80
scheduleMethod · 0.80
initMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected