Pythonidaer / reddie

React app for saving and retrieving Reddit comments.
0 stars 1 forks source link

There is a Bug in the <DynamicPost/> code, resulting in "View Comments" <Button /> not working #8

Closed Pythonidaer closed 1 year ago

Pythonidaer commented 1 year ago

The issue has to do with how the recursive functionality is setup and wired to a handleClick function.

It appears that one of the root causes stems from the fact that "post.url" isn't necessarily what I first thought it was (always a reddit URL).

If it's an outside link, it could basically be like saying: msn.com/politics.json (the reddit API has .json suffixes but only the Reddit urls).

If it's an image link, it could basically be like saying: random.jpg.json

Need to set up a test playground to reinvestigate the post data to see if there is a better key that can be used here.


Notes to Replicate the Issue:

  1. Search the fantasyfootball subreddit
  2. Click on a 'See Post' link where no text appears (it's probably a post to an outside/non-Reddit link)
  3. At this point, your url should look like this: reddie.herokuapp.com/dynamicPost/:id (mine said 135yI36)
  4. Using React Developer Tools, inspect the page and click Components
  5. Find the lu key under Container > Row > Col (I have no idea why it says lu)
  6. This has a props -> post object past to it (my url key said: https://twsn.net/2023/05/post-draft-running-back-fallers)
  7. Permalink key says: /r/fantasyfootball/comments/135yl36/travis_etienne_is_overpriced_as_dynasty_rb7/

Compare to Post with Normal Body:

  1. post.url reads: "https://www.reddit.com/r/learnjavascript/comments/1363tah/cant_replace_backslash_in_a_string_with_regex/"

Closing thoughts:

  1. post.url should not be used for "View Comments" / handleClick functionality - post.permalink should be (will likely need https://www.reddit.com prepended)
  2. This may also fix Comment functionality that isn't working for posts without selftext (body text)
  3. post.url should still be utilized, because it is nice to click it and just have a link open up to the news article/photo/ etc.
  4. The point is that it shouldn't lead to unexpected behaviors, such as broken Comment functionality which is the sole point of this project in the first place.
Pythonidaer commented 1 year ago

I believe I fixed this one. Will review main deploy later on to confirm (tested in 'test' branch first).