Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#36 | BUG/3 Suggestions and original sentences are loaded simultaneously | Artem #37

Closed
wants to merge 1 commit into from

Conversation

filkovskyy
Copy link
Contributor

@filkovskyy filkovskyy commented Oct 11, 2023

Description

Suggestions and original sentences are loaded simultaneously.

The changes ensure that the original sentence and suggestions are initially set to "Loading..." and only change when the suggestions are fully loaded from the API.

Changes:

  1. Defined a new function getSuggestionsFromApi at the beginning of the Home function. This function is responsible for fetching suggestions from the API, updating the suggestions state, setting the original sentence, and updating the loading state.

  2. Modified the loadRandomSentenceFromFile function inside the first useEffect hook to call getSuggestionsFromApi after fetching the random sentence. This ensures that the original sentence is set only after the suggestions have been loaded.

  3. Modified the second useEffect hook to call getSuggestionsFromApi only when randomText is not "Loading...". This ensures that the suggestions are fetched and the loading state is updated only when the original sentence is not in the loading state.

Related to

Bug fix #36

Checklist:

  • My code follows the style guidelines of this project
  • I have carefully reviewed my own code
  • I have commented my code
  • I have updated any documentation

@render
Copy link

render bot commented Oct 11, 2023

Comment on lines +39 to +43
useEffect(() => {
if (randomText !== "Loading...") {
getSuggestionsFromApi(randomText);
}
}, [randomText]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this implementation and it will be great to incorporate this with the LoadingSuggestion which is a spinning image from BUG-1 fix.

@sztupy
Copy link
Contributor

sztupy commented Oct 11, 2023

Hi, do note there's a conflict between this and the loading page fix code. Also note the loading page fix did already solve this partially, so make sure this piece of code is actually still required or not

@sztupy
Copy link
Contributor

sztupy commented Oct 12, 2023

Going to close this as I believe it's not needed anymore with the spinner solution we have right now. Feel free to re-open if you still believe this is useful

@sztupy sztupy closed this Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG/3: No loading message after new sentence is loaded up
3 participants