-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Encapsulate valid label fetching to FlaggableElement
#593
Conversation
… from that within FlaggableElement. This allows FlaggableElement to fetch all its own data and remove the need to pipe labels through a series of components
Blocking on #590 before marking ready for review so I can merge. |
I see code 422 (unprocessable entity) responses when submitting the label report on the rank pages, is this expected? Also I get the same on the labeling pages (but I'm not sure is we are planning to have the flags there). |
Good catch, I didn't catch that. Fixed now |
Posted #614 as a future cleanup around messages. The types are pretty confusing and different depending on use case. |
import { oasstApiClient } from "src/lib/oasst_api_client"; | ||
|
||
/** | ||
* TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you did the review carefully. TODO was to write the handler comments. done :)
/** | ||
* TODO | ||
*/ | ||
const handler = async (req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use one of the middlewares here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Closes #584
This creates a new api route
/api/valid_labels
that returns the list of valid labels that can apply to any message.FlaggableElement
is updated to dynamically fetch labels from the new route and cache them. This allowsFlaggableElement
to be used anywhere without needing to pipe in the valid labels from call sites. This still calls the api route once per page load.