@@ -14,6 +14,7 @@ import {
1414 deleteTestRun ,
1515} from "./testRun.context" ;
1616import { API_URL } from "../_config/env.config" ;
17+ import { useProjectState } from "./project.context" ;
1718
1819interface IConnectAction {
1920 type : "connect" ;
@@ -53,6 +54,7 @@ function socketReducer(state: State, action: IAction): State {
5354function SocketProvider ( { children } : SocketProviderProps ) {
5455 const [ state , dispatch ] = React . useReducer ( socketReducer , initialState ) ;
5556 const { selectedBuild } = useBuildState ( ) ;
57+ const { selectedProjectId } = useProjectState ( ) ;
5658 const testRunDispatch = useTestRunDispatch ( ) ;
5759 const buildDispatch = useBuildDispatch ( ) ;
5860
@@ -65,11 +67,16 @@ function SocketProvider({ children }: SocketProviderProps) {
6567 state . socket . removeAllListeners ( ) ;
6668
6769 state . socket . on ( "build_created" , function ( build : Build ) {
68- addBuild ( buildDispatch , build ) ;
70+ if ( build . projectId === selectedProjectId ) {
71+ addBuild ( buildDispatch , build ) ;
72+ }
6973 } ) ;
7074
7175 state . socket . on ( "build_updated" , function ( builds : Array < Build > ) {
72- updateBuild ( buildDispatch , builds ) ;
76+ updateBuild (
77+ buildDispatch ,
78+ builds . filter ( ( build ) => build . projectId === selectedProjectId )
79+ ) ;
7380 } ) ;
7481
7582 state . socket . on ( "testRun_created" , function ( testRuns : Array < TestRun > ) {
@@ -104,7 +111,13 @@ function SocketProvider({ children }: SocketProviderProps) {
104111 ) ;
105112 } ) ;
106113 }
107- } , [ state . socket , selectedBuild , buildDispatch , testRunDispatch ] ) ;
114+ } , [
115+ state . socket ,
116+ selectedBuild ,
117+ selectedProjectId ,
118+ buildDispatch ,
119+ testRunDispatch ,
120+ ] ) ;
108121
109122 return (
110123 < SocketStateContext . Provider value = { state } >
0 commit comments