Make sure there are no null objects returned from backend
Why: A parallel user interaction may block a room (forever). Here is an example:
Assume 2 persons in the same room with some goals. Then, the following happens:
- User 1 starts dragging one of the goals
- User 2 removes the goal
- User 1 finishes his operation by dropping a goal
At this point, the room is blocked: no view buttons react to clicks, as the following console error appears:
Uncaught TypeError: Cannot read properties of null (reading 'completed')
at index.js:19:41
at Array.filter (
The error is caused because the "GET wss://mobti.me/room" call returns a null goal alongside others:
{
"type": "goals:update",
"goals": [
{
"id": "...",
"text": "...",
"completed": true
},
null,
{
"id": "...",
"text": "...",
"completed": false
}
]
}
What is better when dropping an item:
- it disappears
- It reappears
- The drop is invalidated (similar to 1 but the dragging user gets notified)
@mrozbarry IMO option 2 (it reappears) is better, as it is much easier to click a button to delete than to write the whole thing again.
Edit: since the whole story happens due to a miscommunication in a team, getting their back should be a nice touch.