tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
291
fork
atom
a tool for shared writing and social publishing
291
fork
atom
overview
issues
27
pulls
pipelines
delete facts in write cache if delete entity
awarm.space
6 months ago
66dea5ef
4d9e4593
+5
-10
1 changed file
expand all
collapse all
unified
split
src
replicache
cachedServerMutationContext.ts
+5
-10
src/replicache/cachedServerMutationContext.ts
···
124
124
if (!(await this.checkPermission(entity))) return;
125
125
deleteEntitiesCache.push(entity);
126
126
entitiesCache = entitiesCache.filter((e) => e.id !== entity);
127
127
+
writeCache = writeCache.filter(
128
128
+
(f) =>
129
129
+
f.type !== "put" ||
130
130
+
(f.fact.entity !== entity && f.fact.data.value !== entity),
131
131
+
);
127
132
},
128
133
async assertFact(f) {
129
134
if (!f.entity) return;
···
136
141
let existingFact = await scanIndex.eav(f.entity, f.attribute);
137
142
if (existingFact[0]) {
138
143
id = existingFact[0].id;
139
139
-
if (attribute.type === "text") {
140
140
-
let c =
141
141
-
textAttributeWriteCache[`${f.entity}-${f.attribute}`] || {};
142
142
-
textAttributeWriteCache[`${f.entity}-${f.attribute}`] = {
143
143
-
...c,
144
144
-
[clientID]: (
145
145
-
data as Fact<keyof FilterAttributes<{ type: "text" }>>["data"]
146
146
-
).value,
147
147
-
};
148
148
-
}
149
144
}
150
145
}
151
146
writeCache = writeCache.filter((f) => f.fact.id !== id);