A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: remove `document as any` in page-visibility
Abdullah Atta77ac53215c21
diff --git a/apps/web/src/utils/page-visibility.ts b/apps/web/src/utils/page-visibility.tsindex 05a4f8ff6..ffa5cf128 100644--- a/apps/web/src/utils/page-visibility.ts+++ b/apps/web/src/utils/page-visibility.ts@@ -17,15 +17,20 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-function getVisibilityChangeParams() {- if ("msHidden" in document) {- return ["msHidden", "msvisibilityChange"] as const;- } else if ("webkitHidden" in document) {- return ["webkitHidden", "webkitvisibilityChange"] as const;- } else {- // Opera 12.10 and Firefox 18 and later support- return ["hidden", "visibilityChange"] as const;- }+function visibilityChange() {+ return "msHidden" in document+ ? "msvisibilityChange"+ : "webkitHidden" in document+ ? "webkitvisibilityChange"+ : "visibilityChange";+}++function isDocumentHidden() {+ return "msHidden" in document && typeof document.msHidden === "boolean"+ ? document.msHidden+ : "webkitHidden" in document && typeof document.webkitHidden === "boolean"+ ? document.webkitHidden+ : document.hidden;}export function onPageVisibilityChanged(@@ -38,9 +43,8 @@ export function onPageVisibilityChanged(onDeviceOffline(() => handler("offline", false));// Handle page visibility change- const [hidden, visibilityChange] = getVisibilityChangeParams();- document.addEventListener(visibilityChange, () =>- handler("visibilitychange", (document as any)[hidden])+ document.addEventListener(visibilityChange(), () =>+ handler("visibilitychange", isDocumentHidden()));}