web: try to reconnect sync on window focus

This commit is contained in:
Abdullah Atta
2023-04-28 10:35:58 +05:00
committed by Abdullah Atta
parent abb89ecbc3
commit 1e5f13087b

View File

@@ -35,7 +35,7 @@ function isDocumentHidden() {
export function onPageVisibilityChanged(
handler: (
status: "online" | "offline" | "visibilitychange",
status: "online" | "offline" | "visibilitychange" | "focus",
bool: boolean
) => void
) {
@@ -46,6 +46,8 @@ export function onPageVisibilityChanged(
document.addEventListener(visibilityChange(), () =>
handler("visibilitychange", isDocumentHidden())
);
window.addEventListener("focus", () => handler("focus", false));
}
function onDeviceOnline(handler: () => void) {