in webapp/lib/handle-realtime-event.ts [18:29]
function updateOrAddItem(id: string, updates: Partial<Item>): void {
setItems((prev) => {
const idx = prev.findIndex((m) => m.id === id);
if (idx >= 0) {
const updated = [...prev];
updated[idx] = { ...updated[idx], ...updates };
return updated;
} else {
return [...prev, createNewItem({ id, ...updates })];
}
});
}