Untitled

 avatar
unknown
plain_text
2 years ago
1.6 kB
6
Indexable
  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();
      }
    }
Editor is loading...