tryton-vanmeer / ProtonDB-for-Steam

Shows ratings from protondb.com on Steam
GNU General Public License v3.0
168 stars 3 forks source link

Badge is displayed several times per game on wishlist #37

Closed Deuchnord closed 9 months ago

Deuchnord commented 2 years ago

Expected Behaviour:

On wishlist, the badge should be displayed only once per game.

Actual Behaviour:

The badge is displayed several times (generally twice or three times).

Issue screenshot

Steps to Reproduce:

  1. Open your wishlist
  2. Contemplate the badges

Details

Browser:

Browser Version: 103.0.2

Addon Version: 1.8.1

RunningDroid commented 1 year ago

Refreshing the page can get rid of the extra badges, but they start coming back if you scroll down the page: Screenshot 2022-12-11 at 19-06-55 RunningDroid's wishlist

Browser: Firefox 107.0.1

Addon Version: 1.8.1

shigutso commented 1 year ago

Same issue here. Firefox 108.0.1 Addon 1.8.1

Rayquaza01 commented 1 year ago

This occurs when the script takes more than 1 second to add a badge. The script tries to load badges every second, skipping over games it has already added a badge to. If the page is loading slowly, it adds multiple (because it retries before it finished processing the first time). I'm not entirely sure why, but this can be fixed by adjusting ProtonDB.request_rating() to use a promise instead of a callback, and changing Wishlist.load_ratings() to be async, and awaiting the ProtonDB request.

Here's a video demo reproducing it with the Firefox devtools throttling: https://www.youtube.com/watch?v=NoZkZqIUAzw

And here's the branch that fixes it by changing to to a promise: https://github.com/Rayquaza01/ProtonDB-for-Steam/tree/promise

tryton-vanmeer commented 9 months ago

Fixed in 404fe3d407c0aa0ff1f2b8eb7956ae84349c3233