Merge pull request #758 from LAION-AI/753-label-all-messages

Switch back to useEffect in FlaggableElement
This commit is contained in:
AbdBarho
2023-01-16 07:50:22 +01:00
committed by GitHub
+9 -7
View File
@@ -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: () => {