Xyphyn / photon

A replacement for lemmy-ui with more features, a better design, and more customizability.
https://phtn.app
GNU Affero General Public License v3.0
348 stars 39 forks source link

Number of Crossposts Inaccurate and Increases #410

Open pbui opened 3 weeks ago

pbui commented 3 weeks ago

Describe the bug

The number of crossposts is inaccurate (too large) as shown here:

Screenshot from 2024-08-19 07-30-42

For the post, https://photon.ndlug.org/post/lemmy.ndlug.org/1001830, there should only be one crosspost to https://photon.ndlug.org/post/lemmy.ndlug.org/1001831

However, Photon reports there are two crossposts. Moreover, if I go to the post page and then go back to the listing page (and go back and forth), the number goes up over time as shown here:

Screenshot from 2024-08-19 07-31-15

To Reproduce (if applicable) Steps to reproduce the behavior:

  1. Make a post.
  2. Crosspost to another community
  3. Notice that the number of crossposts is more than one.

Expected behavior

The number of crossposts should be accurate and should not increase by navigating back and forth.

Screenshots

Shown above.

Versions

pbui commented 6 days ago

Looking at https://github.com/Xyphyn/photon/blob/23834137a707e51e003e65650218bf805676ac88/src/lib/components/lemmy/post/feed/crosspost.ts#L53

it appears that you have a seenUrls data structure to track URLs already seen (and probably to prevent duplicates), but you never actually check if the URL is in seenUrls... which is probably why we have duplicates.

I think there just needs to be a check somewhere here, but I'm not sure exactly what all the code is doing to be able to determine where the check should be.