Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/mudita/mudita-center int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
MateuszMudita committed Aug 28, 2024
2 parents 668e34c + 7e95c77 commit d4c86bc
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import { useEffect } from "react"
import { updateOnlineStatus } from "./base.action"
import { updateOnlineStatusRequest } from "./online-status.requests"
import { useDispatch } from "react-redux"

export const useOnlineListener = () => {
const dispatch = useDispatch()

useEffect(() => {
updateOnlineStatus(window.navigator.onLine)
dispatch(updateOnlineStatus(window.navigator.onLine))
void updateOnlineStatusRequest(window.navigator.onLine)
const handleOnlineStatus = () => {
updateOnlineStatus(window.navigator.onLine)
dispatch(updateOnlineStatus(window.navigator.onLine))
void updateOnlineStatusRequest(window.navigator.onLine)
}

Expand All @@ -23,5 +26,5 @@ export const useOnlineListener = () => {
window.removeEventListener("online", handleOnlineStatus)
window.removeEventListener("offline", handleOnlineStatus)
}
}, [])
}, [dispatch])
}

0 comments on commit d4c86bc

Please sign in to comment.