tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
check permissions on retractions
awarm.space
1 month ago
1021011d
3ccb429f
+14
1 changed file
expand all
collapse all
unified
split
src
replicache
cachedServerMutationContext.ts
+14
src/replicache/cachedServerMutationContext.ts
···
155
155
});
156
156
},
157
157
async retractFact(factID) {
158
158
+
let cachedFact = writeCache.find(
159
159
+
(f) => f.type === "put" && f.fact.id === factID,
160
160
+
);
161
161
+
let entity: string | undefined;
162
162
+
if (cachedFact && cachedFact.type === "put") {
163
163
+
entity = cachedFact.fact.entity;
164
164
+
} else {
165
165
+
let [row] = await tx
166
166
+
.select({ entity: facts.entity })
167
167
+
.from(facts)
168
168
+
.where(driz.eq(facts.id, factID));
169
169
+
entity = row?.entity;
170
170
+
}
171
171
+
if (!entity || !(await this.checkPermission(entity))) return;
158
172
writeCache = writeCache.filter((f) => f.fact.id !== factID);
159
173
writeCache.push({ type: "del", fact: { id: factID } });
160
174
},