Skip to content

Commit

Permalink
Fix bug in delete implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
aboodman committed Dec 28, 2021
1 parent cd982ad commit aa22fb5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
1 change: 0 additions & 1 deletion STATUS
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ status
merging the pending queues
- each time we receive a push, the delay gets reset
- need to rework how peek() works
- delete is broken
- clear is broken
- implement alpha fading again

Expand Down
2 changes: 1 addition & 1 deletion backend/process/process-pending.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ function sendPokes(
pokes: Map<RoomID, ClientPokeBody[]>,
rooms: RoomMap
) {
lc.debug?.("sending pokes", pokes);
for (const [roomID, pokesForRoom] of pokes) {
const roomState = must(rooms.get(roomID));
for (const pokeBody of pokesForRoom) {
const client = must(roomState.clients.get(pokeBody.clientID));
const poke: PokeMessage = ["poke", pokeBody.poke];
lc.debug?.("sending client", pokeBody.clientID, "poke", pokeBody.poke);
client.socket.send(JSON.stringify(poke));
}
}
Expand Down
23 changes: 13 additions & 10 deletions backend/storage/replicache-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,20 @@ export function unwrapPatch(inner: Patch): Patch {
const unwrappedKey = key.substring(userValuePrefix.length);
if (op === "put") {
const userValue = p.value as UserValue;
return {
op: "put",
key: unwrappedKey,
value: userValue.value,
};
} else if (op === "del") {
return {
op: "del",
key: unwrappedKey,
};
if (userValue.deleted) {
return {
op: "del",
key: unwrappedKey,
};
} else {
return {
op: "put",
key: unwrappedKey,
value: userValue.value,
};
}
} else {
// We don't use del or clear at this layer
throw new Error(`unexpected op: ${op}`);
}
});
Expand Down

0 comments on commit aa22fb5

Please sign in to comment.