mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-18 12:04:45 +08:00
fix: fix replay loading
This commit is contained in:
@@ -1,19 +1,25 @@
|
|||||||
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
|
import { useReplay } from "../replay";
|
||||||
|
|
||||||
import { fetchReplayTitle } from "./chat";
|
import { fetchReplayTitle } from "./chat";
|
||||||
|
|
||||||
export function useReplayMetadata() {
|
export function useReplayMetadata() {
|
||||||
|
const { isReplay } = useReplay();
|
||||||
const [title, setTitle] = useState<string | null>(null);
|
const [title, setTitle] = useState<string | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const isLoading = useRef(false);
|
||||||
const [error, setError] = useState<boolean>(false);
|
const [error, setError] = useState<boolean>(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (title || isLoading) {
|
if (!isReplay) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setIsLoading(true);
|
if (title || isLoading.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isLoading.current = true;
|
||||||
fetchReplayTitle()
|
fetchReplayTitle()
|
||||||
.then((title) => {
|
.then((title) => {
|
||||||
setError(false);
|
setError(false);
|
||||||
@@ -28,8 +34,8 @@ export function useReplayMetadata() {
|
|||||||
document.title = "DeerFlow";
|
document.title = "DeerFlow";
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setIsLoading(false);
|
isLoading.current = false;
|
||||||
});
|
});
|
||||||
}, [isLoading, title]);
|
}, [isLoading, isReplay, title]);
|
||||||
return { title, isLoading, hasError: error };
|
return { title, isLoading, hasError: error };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user