BGWE / BoardgameWE

Backend of the Board Game Componion application.
MIT License
2 stars 0 forks source link

When a user adds a Board Game to an Event, ask to add it to his/her library as well #33

Closed FServais closed 5 years ago

FServais commented 5 years ago

Give the possibility to the user to add a Board Game to his/her library when adding it to an Event.

waliens commented 5 years ago

I feel it is cleaner to issue two API calls for this one. It makes sense because those are two independent actions. If we adopt this strategy, the endpoints are already ready: POST /event/:eid/board_games and POST /user/:uid/library_games.

FServais commented 5 years ago

Would it be more efficient to have an API that checks if a board game (from BGG ID or BGWE ID or both ?) is already in a user’s library? Or should the UI query for all the bgs in a user’s lib?

waliens commented 5 years ago

I'm not sure to understand what you propose :)

In any case, the (not yet implemented) endpoints for adding games from BGGs could be used instead of the ones I am talking about above. In this case, you would have:

instead of:

In terms of efficiency:

FServais commented 5 years ago

Sorry, not what I meant :)

Let's say that a User adds a bg to an event. 2 cases:

  1. User doesn't have it in its lib, we ask to add it to his/her lib.
  2. User does have it, in which case we skip that question.

How do we determine if BG is already in User's lib? :)

  1. Via an API (like GET /user/library_games/:bgid
  2. Use GET /user/library_games, then see if it is there
waliens commented 5 years ago

You don't have to check that. If you try to add a game that is already in an event/a library, the server won't change the database and will return a 200 OK response.

FServais commented 5 years ago

What I would like is to not propose to add it if it is already in the lib :)

waliens commented 5 years ago

Ok ! I see two options:

  1. Issue a "GET /user/library_games" call when landing on the event games page. You need it anyway for listing/filtering games to be added to the event (we talked about this more or less few weeks ago). Then you can check if the game is in the library by looking for it in the list.
  2. Avoid the problem by adding a checkbox "Add to my library if not in it yet". It is not so much burden to leave a checkbox I guess

I don't like the idea of issuing a request only for checking that a game is in the library.

FServais commented 5 years ago

Ask user to add to library via Snackbar