📜 ⬆️ ⬇️

Doubles appear in favorites

In habrahabr there is a bug: creating duplicates in favorites.
There are two ways to repeat it:
1) if you quickly click on the “add to favorites” icon, then at a certain point the browser will send 2 ajax requests to add to favorites;
2) open 2 identical pages and click on the “add to favorites” icon of the same article in both windows.

Decision:
1) client side:
add delay (setTimeOut ()) to js to send 500 milliseconds will be enough;
2) on the server side:
In the server script, check for the presence of the selected article in the user.

When deleting from favorites, it is better to delete all entries, some one is being deleted, because there must be a one-to-one relationship, one article - one favorites.

')

Source: https://habr.com/ru/post/42083/


All Articles