mobtime icon indicating copy to clipboard operation
mobtime copied to clipboard

Make sure there are no null objects returned from backend

Open KucherenkoSerhiy opened this issue 2 years ago • 2 comments

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 () at getGoalsDetails (index.js:19:27) at tabs (index.js:70:20) at view (timer.js:77:13) at render (index.js?module=1:393:10)

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
    }
  ]
}

KucherenkoSerhiy avatar Mar 11 '23 21:03 KucherenkoSerhiy

What is better when dropping an item:

  1. it disappears
  2. It reappears
  3. The drop is invalidated (similar to 1 but the dragging user gets notified)

mrozbarry avatar Mar 11 '23 23:03 mrozbarry

@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.

KucherenkoSerhiy avatar Mar 11 '23 23:03 KucherenkoSerhiy