Untitled
unknown
plain_text
3 years ago
2.4 kB
9
Indexable
const handleSelect = async (topic) => {
setLoading(true);
setTopicId(topic.id);
setTopic(topic);
setLoading(false);
// console.log(topic, 8596);
const apiTopics =
process.env.REACT_APP_BASE_API ===
"https://demo1-services.tima-online.com/api"
? await topicApi?.getTopic(topic?.id)
: null;
const updateData = () => {
if (!apiTopics) return
setTopics(apiTopics?.ChildTopics);
setClickedTopic(topic);
setTopicId(topic.id);
setTopic(topic);
setLoading(false);
};
console.log(!apiTopics, 5555);
if (apiTopics !== null) {
if (apiTopics?.ChildTopics?.length === 0 || !apiTopics?.ChildTopics) {
dispatch(startSession()).then((action) => {
if (action.error) {
if (
action.error.message === "Request failed with status code 401"
) {
setHasError(true);
setDemoCodeDialogOpen(true);
}
return;
}
setCurReading([action.payload.data.welcomeText]);
setWavesActive(true);
// read text here to avoid issues on iOS (audio playback needs to be triggered by user interaction)
dispatch(
readText({
text: action.payload.data.welcomeText,
callback: () => {
setCurReading([]);
setWavesActive(false);
},
persist: true,
})
);
updateData();
history.push("/chat");
});
} else {
updateData();
}
}
if (apiTopics === null) {
dispatch(startSession()).then((action) => {
if (action.error) {
if (action.error.message === "Request failed with status code 401") {
setHasError(true);
setDemoCodeDialogOpen(true);
}
return;
}
setCurReading([action.payload.data.welcomeText]);
setWavesActive(true);
// read text here to avoid issues on iOS (audio playback needs to be triggered by user interaction)
dispatch(
readText({
text: action.payload.data.welcomeText,
callback: () => {
setCurReading([]);
setWavesActive(false);
},
persist: true,
})
);
history.push("/chat");
});
}
};Editor is loading...