akshitagupta15june / Moksh

Unlock your potential and achieve true balance in life with Moksh
https://akshitagupta15june.github.io/Moksh/
MIT License
213 stars 427 forks source link

fix: initial tweet click contains quote and author #1599

Closed Shobhit-Nagpal closed 1 month ago

Shobhit-Nagpal commented 1 month ago

Tweet button under Gita shlok generator does not paste correct text on Twitter

Closes: #1545

Description

The initial problem was that when the page renders and the first shlok shows up, upon clicking the tweet button, we'd be redirected to Twitter but the quote and author would be empty.

Upon going through the code, I saw we're using inner HTML actions such as onclick directly within the necessary tags. In the tweet button, we're calling the tweetQuote function but when the javascript file is loaded, we've initialized the quote and author to be empty. This is why when we want to tweet the first quote, the initial quote is empty on thw twitter prompt.

The fix for this was to simply initialize the quote and author with the same as the one being loaded in the HTML initially. Along with this, I also added a check in the genQuote function to prevent repeating of the same quote. One thing to note is that some quotes are repeated in the array itself. Other than that, the same quote shouldn't render.

Screenshots

1. First quote:

image

2. After pressing the tweet button:

image

Checklist