mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-10-17 11:16:13 +02:00
remove default value changes
This commit is contained in:
parent
f892a821f5
commit
13c2c582ad
@ -72,14 +72,13 @@ export function MqttProvider({
|
|||||||
return <Mqtt.Provider value={{ state, ws: wsRef.current }}>{children}</Mqtt.Provider>;
|
return <Mqtt.Provider value={{ state, ws: wsRef.current }}>{children}</Mqtt.Provider>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useMqtt(watchTopic, publishTopic, defaultValue = null) {
|
export function useMqtt(watchTopic, publishTopic) {
|
||||||
const { state, ws } = useContext(Mqtt);
|
const { state, ws } = useContext(Mqtt);
|
||||||
|
|
||||||
const value = state[watchTopic] || { payload: null };
|
const value = state[watchTopic] || { payload: null };
|
||||||
|
|
||||||
const send = useCallback(
|
const send = useCallback(
|
||||||
(payload) => {
|
(payload) => {
|
||||||
payload = payload || defaultValue;
|
|
||||||
ws.send(
|
ws.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
topic: publishTopic || watchTopic,
|
topic: publishTopic || watchTopic,
|
||||||
@ -87,7 +86,7 @@ export function useMqtt(watchTopic, publishTopic, defaultValue = null) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[ws, watchTopic, publishTopic] // eslint-disable-line react-hooks/exhaustive-deps
|
[ws, watchTopic, publishTopic]
|
||||||
);
|
);
|
||||||
|
|
||||||
return { value, send, connected: state.__connected };
|
return { value, send, connected: state.__connected };
|
||||||
@ -122,8 +121,9 @@ export function useSnapshotsState(camera) {
|
|||||||
|
|
||||||
export function useRestart() {
|
export function useRestart() {
|
||||||
const {
|
const {
|
||||||
|
value: { payload },
|
||||||
send,
|
send,
|
||||||
connected,
|
connected,
|
||||||
} = useMqtt('', 'restart', 'container');
|
} = useMqtt('restart', 'restart');
|
||||||
return { send, connected };
|
return { payload, send, connected };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user