mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-27 16:10:30 +08:00
Switch back to useEffect in FlaggableElement to ensure valid labels are present
This commit is contained in:
@@ -22,7 +22,7 @@ import {
|
||||
} from "@chakra-ui/react";
|
||||
import { QuestionMarkCircleIcon } from "@heroicons/react/20/solid";
|
||||
import clsx from "clsx";
|
||||
import { useReducer } from "react";
|
||||
import { useEffect, useReducer } from "react";
|
||||
import { FiAlertCircle } from "react-icons/fi";
|
||||
import { get, post } from "src/lib/api";
|
||||
import { Message } from "src/types/Conversation";
|
||||
@@ -100,12 +100,14 @@ export const FlaggableElement = (props: FlaggableElementProps) => {
|
||||
);
|
||||
const [isEditing, setIsEditing] = useBoolean();
|
||||
|
||||
useSWR("/api/valid_labels", get, {
|
||||
onSuccess: (data) => {
|
||||
const { valid_labels } = data;
|
||||
updateReport({ type: "load_labels", labels: valid_labels });
|
||||
},
|
||||
});
|
||||
const { data, isLoading } = useSWR("/api/valid_labels", get);
|
||||
useEffect(() => {
|
||||
if (isLoading) {
|
||||
return;
|
||||
}
|
||||
const { valid_labels } = data;
|
||||
updateReport({ type: "load_labels", labels: valid_labels });
|
||||
}, [data, isLoading]);
|
||||
|
||||
const { trigger } = useSWRMutation("/api/set_label", post, {
|
||||
onSuccess: () => {
|
||||
|
||||
Reference in New Issue
Block a user