hiyaryan / the-cdj

The Cognitive Distortion Journal (CDJ) is a smart journaling tool that helps remedy distorted thinking. It can feel impossible to follow the CBT technique of labeling distorted thinking and finding alternative modes of thought (i.e. reframing) while cognitive distortions are occurring. The CDJ does that work for you. -- The CDJ is in beta testing!!
https://thecdj.app
3 stars 0 forks source link

Allow user to work while waiting for an analysis. #57

Open hiyaryan opened 7 months ago

hiyaryan commented 7 months ago

When a user edits an entry or requests a new analysis, the Thoughts section is disabled preventing the user from viewing or editing any other thought until the analysis has been generated. This might be anywhere from a few seconds to longer depending on multiple factors. The Thoughts sections is disabled by checking if the isSubmitting state variable from its parent component is true.

It was decided that disabling the Thoughts would be a simple solution to an old issue that was closed #53. In summary, if a user clicked on an entry while awaiting a response, the LinearProgress bar would appear on every Analysis saying to wait for a new analysis. This only makes sense for the entry that the user actually requested a new analysis on. If the user was on a different entry when a new analysis was returned, the typeWriter effect would run on the post they were viewing making it seem like the post they were viewing was being updated, which is not the case.

Ideally, the user would be able to work or navigate around while waiting for a new analysis. This seems like it will require more than just a little refactoring such as creating a new component to store each entry. This would make each entry its own component which would open the application up to more features.

One minor fix this would allow is moving the CircularProgress component that runs when a Thought is edited to the Entry itself indicating that something is happening for a particular Entry as opposed to the entire Recent Thoughts section.

Note that if each Thought is wax made to be a standalone component, then some renaming may be useful here. The name Entry is used to indicate the TextField component for which a new thought is submitted. It may be better to rename it to ThoughtEntry, and the new component discussed in this issue to Thought, which is a child of Thoughts (or even better RecentThoughts).

hiyaryan commented 3 months ago

Consider using SSE. Which would allow the user to make a request, and get an OK response. Then when the server is done processing, the server can send the data to update the UI using SSE.