a tool for shared writing and social publishing

await async ops in removeBlock

+5 -5
+5 -5
src/replicache/mutations.ts
··· 312 312 "block/is-locked", 313 313 ); 314 314 if (isLocked?.data.value) continue; 315 - let images = await ctx.scanIndex.eav(block.blockEntity, "block/image"); 316 - ctx.runOnServer(async ({ supabase }) => { 317 - for (let image of images) { 315 + let [image] = await ctx.scanIndex.eav(block.blockEntity, "block/image"); 316 + await ctx.runOnServer(async ({ supabase }) => { 317 + if (image) { 318 318 let paths = image.data.src.split("/"); 319 319 await supabase.storage 320 320 .from("minilink-user-assets") 321 321 .remove([paths[paths.length - 1]]); 322 322 } 323 323 }); 324 - ctx.runOnClient(async () => { 324 + await ctx.runOnClient(async () => { 325 325 let cache = await caches.open("minilink-user-assets"); 326 - for (let image of images) { 326 + if (image) { 327 327 await cache.delete(image.data.src + "?local"); 328 328 } 329 329 });