mirror of
				https://github.com/blakeblackshear/frigate.git
				synced 2025-10-27 10:52:11 +01:00 
			
		
		
		
	fix websocket from spreading stale state (#14466)
This commit is contained in:
		
							parent
							
								
									6c70e56059
								
							
						
					
					
						commit
						8fcb8e54f7
					
				@ -65,7 +65,10 @@ function useValue(): useValueReturn {
 | 
				
			|||||||
        : "OFF";
 | 
					        : "OFF";
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    setWsState({ ...wsState, ...cameraStates });
 | 
					    setWsState((prevState) => ({
 | 
				
			||||||
 | 
					      ...prevState,
 | 
				
			||||||
 | 
					      ...cameraStates,
 | 
				
			||||||
 | 
					    }));
 | 
				
			||||||
    setHasCameraState(true);
 | 
					    setHasCameraState(true);
 | 
				
			||||||
    // we only want this to run initially when the config is loaded
 | 
					    // we only want this to run initially when the config is loaded
 | 
				
			||||||
    // eslint-disable-next-line react-hooks/exhaustive-deps
 | 
					    // eslint-disable-next-line react-hooks/exhaustive-deps
 | 
				
			||||||
@ -77,7 +80,10 @@ function useValue(): useValueReturn {
 | 
				
			|||||||
      const data: Update = JSON.parse(event.data);
 | 
					      const data: Update = JSON.parse(event.data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (data) {
 | 
					      if (data) {
 | 
				
			||||||
        setWsState({ ...wsState, [data.topic]: data.payload });
 | 
					        setWsState((prevState) => ({
 | 
				
			||||||
 | 
					          ...prevState,
 | 
				
			||||||
 | 
					          [data.topic]: data.payload,
 | 
				
			||||||
 | 
					        }));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    onOpen: () => {
 | 
					    onOpen: () => {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user