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
use fallback if replicache hasn't initialized yet
awarm.space
2 years ago
d78a2c61
73b3e836
+5
-2
2 changed files
expand all
collapse all
unified
split
replicache
index.tsx
pull.ts
+4
-2
replicache/index.tsx
···
126
);
127
let data = useSubscribe(
128
rep,
129
-
(tx) => {
0
0
130
return tx
131
.scan<Fact<A>>({ indexName: "eav", prefix: `${entity}-${attribute}` })
132
.toArray();
···
136
dependencies: [entity, attribute],
137
},
138
);
139
-
let d = data || (attribute === "card/block" ? fallbackData : []);
140
return Attributes[attribute].cardinality === "many"
141
? (d as CardinalityResult<A>)
142
: (d[0] as CardinalityResult<A>);
···
126
);
127
let data = useSubscribe(
128
rep,
129
+
async (tx) => {
130
+
let initialized = await tx.get("initialized");
131
+
if (!initialized) return null;
132
return tx
133
.scan<Fact<A>>({ indexName: "eav", prefix: `${entity}-${attribute}` })
134
.toArray();
···
138
dependencies: [entity, attribute],
139
},
140
);
141
+
let d = data || fallbackData;
142
return Attributes[attribute].cardinality === "many"
143
? (d as CardinalityResult<A>)
144
: (d[0] as CardinalityResult<A>);
+1
replicache/pull.ts
···
33
lastMutationIDChanges: clientGroup,
34
patch: [
35
{ op: "clear" },
0
36
...facts.map((f) => {
37
return {
38
op: "put",
···
33
lastMutationIDChanges: clientGroup,
34
patch: [
35
{ op: "clear" },
36
+
{ op: "put", key: "initialized", value: true },
37
...facts.map((f) => {
38
return {
39
op: "put",