a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

don't do yjs merges on server

+2 -25
+2 -25
src/replicache/cachedServerMutationContext.ts
··· 6 6 import * as driz from "drizzle-orm"; 7 7 import { Attribute, Attributes, FilterAttributes } from "./attributes"; 8 8 import { v7 } from "uuid"; 9 - import * as base64 from "base64-js"; 10 - import * as Y from "src/ywasm"; 11 9 import { DeepReadonly } from "replicache"; 12 10 13 11 type WriteCacheEntry = 14 12 | { type: "put"; fact: Fact<any> } 15 13 | { type: "del"; fact: { id: string } }; 14 + 16 15 export function cachedServerMutationContext( 17 16 tx: PgTransaction<any, any, any>, 18 17 permission_token_id: string, ··· 193 192 ); 194 193 if (factWrites.length > 0) { 195 194 for (let f of factWrites) { 196 - let attribute = Attributes[f.attribute as Attribute]; 197 - let data = f.data; 198 - 199 - // Text merging timing 200 - let textMergeStart = performance.now(); 201 - if (attribute.type === "text" && attribute.cardinality === "one") { 202 - let values = Object.values( 203 - textAttributeWriteCache[`${f.entity}-${f.attribute}`] || {}, 204 - ); 205 - if (values.length > 0) { 206 - let existingFact = await scanIndex.eav(f.entity, f.attribute); 207 - if (existingFact[0] && !values.includes(existingFact[0].data.value)) 208 - values.push(existingFact[0].data.value); 209 - if (values.length > 1) 210 - data.value = base64.fromByteArray( 211 - Y.mergeUpdatesV1(values.map((v) => base64.toByteArray(v))), 212 - ); 213 - } 214 - } 215 - timeTextMerging += performance.now() - textMergeStart; 216 - 217 - // Fact insert timing 218 195 let factInsertStart = performance.now(); 219 196 await tx.transaction((tx2) => 220 197 tx2 ··· 222 199 .values({ 223 200 id: f.id, 224 201 entity: f.entity, 225 - data: driz.sql`${data}::jsonb`, 202 + data: driz.sql`${f.data}::jsonb`, 226 203 attribute: f.attribute, 227 204 }) 228 205 .onConflictDoUpdate({