File tree 1 file changed +19
-1
lines changed
src/frontstage/src/app/projects/[id]
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import toast from "react-hot-toast";
28
28
const ProjectDetailPage : React . FC = ( ) => {
29
29
const params = useParams ( ) ;
30
30
const [ isPolling , setIsPolling ] = useState ( false ) ;
31
+ const [ logs , setLogs ] = useState < any [ ] > ( [ ] ) ;
31
32
32
33
const projectId = params . id as string ;
33
34
const {
@@ -40,14 +41,31 @@ const ProjectDetailPage: React.FC = () => {
40
41
} ) ;
41
42
42
43
const {
43
- data : logs ,
44
+ data : logSet ,
44
45
isLoading : isLogsLoading ,
45
46
error : logsError ,
46
47
refetch : refetchLogs ,
47
48
} = useFetchProjectLogs < any > ( projectId , {
48
49
refetchInterval : isPolling ? 5000 : false , // Poll every 5 seconds if isPolling is true
49
50
} ) ;
50
51
52
+ useEffect ( ( ) => {
53
+ if ( logSet . length ) {
54
+ const uniqueLogs = logSet . filter ( ( newLog : { log : string ; } , index : number ) => {
55
+ return ! logs . some ( ( existingLog , existingIndex ) => {
56
+ try {
57
+ const parsedNewLog = JSON . parse ( newLog . log ) ;
58
+ const parsedExistingLog = JSON . parse ( existingLog . log ) ;
59
+ return parsedNewLog . stream === parsedExistingLog . stream && index === existingIndex ;
60
+ } catch {
61
+ return newLog . log === existingLog . log && index === existingIndex ;
62
+ }
63
+ } ) ;
64
+ } ) ;
65
+ setLogs ( ( prevLogs ) => prevLogs . concat ( uniqueLogs ) ) ;
66
+ }
67
+ } , [ logSet , logs ] ) ;
68
+
51
69
useEffect ( ( ) => {
52
70
if ( project ?. status === "DEPLOYING" ) {
53
71
setIsPolling ( true ) ;
You can’t perform that action at this time.
0 commit comments