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

Candidate Decider - Hide Latency from Listeners through Frontend State Updates #495

Merged
merged 10 commits into from
Sep 26, 2023

Conversation

andrew032011
Copy link
Collaborator

@andrew032011 andrew032011 commented Sep 24, 2023

Summary

Previously, there was a latency issue on the candidate decider related to the listeners needing about a 2-3 second delay to update the responses real-time.

I have "hidden" the latency by updating frontend state instead of solely relying on Firestone listeners to wait for DB updates.

When the listeners receives the new snapshot, the local state will be properly synced. Updates to ratings/comments now show up instantaneously on the candidate decider UI.

Also:

  • Add save button to prevent multi-threading issues (when users spam the ratings really hard the UI glitches out. The save button lets them switch between ratings but then commit the rating they want)
  • For some reason, we were setting the comment to be '' every time we hit the save button, so if you hit the save button twice, you would clear out your comment

Notion/Figma Link

https://www.notion.so/cornelldti/Candidate-Decider-Hide-Latency-from-Listeners-through-Frontend-State-Updates-d020a49d69b3439b93380add5833d6e0?pvs=4

Test Plan

Recorded a demo video for the candidate decider which includes this instantaneous update functionality (skip to 1:50).

Screen.Recording.2023-09-24.at.12.25.34.PM.mov

Notes

Breaking Changes

andrew032011 and others added 7 commits September 23, 2023 13:46
* wip

* prettier and fix typo

* remove leads from list

* limit height of modal height to 60% of viewport height and make scrollable
* remove extraneous } in shoutoutsapi request

* remove console.logs in api.ts
@andrew032011 andrew032011 requested a review from a team as a code owner September 24, 2023 15:28
@dti-github-bot
Copy link
Member

dti-github-bot commented Sep 24, 2023

[diff-counting] Significant lines: 124.

Copy link
Contributor

@oscarwang20 oscarwang20 left a comment

Choose a reason for hiding this comment

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

Can we add a check to see if the form inputs changed before we call the api in handleRatingChange and handleCommentChange? It would just use getRating() and getComment() to check if the current rating and comment are different from what they were originally.

@oscarwang20
Copy link
Contributor

UI suggestion: maybe we could also just have one save button to handle both the rating change and comment change. And to make it clear that we are saving both, we could put the button above the form field:
image

@andrew032011
Copy link
Collaborator Author

UI suggestion: maybe we could also just have one save button to handle both the rating change and comment change. And to make it clear that we are saving both, we could put the button above the form field:

Agreed, done.
Screenshot 2023-09-26 at 5 37 09 PM

@andrew032011
Copy link
Collaborator Author

Can we add a check to see if the form inputs changed before we call the api in handleRatingChange and handleCommentChange? It would just use getRating() and getComment() to check if the current rating and comment are different from what they were originally.

I agree with this to prevent excessive API calls, but I like the added UX of disabling the save button until at least one change (rating or comment) has been made. So I've done that instead. This behavior should also remind them to save too, since the button will light up once they've made a change.

Screen.Recording.2023-09-26.at.5.38.29.PM.mov

Copy link
Contributor

@oscarwang20 oscarwang20 left a comment

Choose a reason for hiding this comment

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

Looks great!

@andrew032011 andrew032011 merged commit 60cda01 into main Sep 26, 2023
13 checks passed
@andrew032011 andrew032011 deleted the u/axc/latency_fix branch September 26, 2023 23:58
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.

3 participants