Add `packages/app/src/constants/platform.ts` with canonical gates (isWeb, isNative, getIsElectron) and refactor all ~100 ad-hoc Platform.OS checks across 69 files to use shared imports. Fix sidebar hover crash on native (onPointerEnter → onHoverIn), fix tooltip to use breakpoint instead of platform detection, make sidebar action buttons always visible on native where hover doesn't work, and document the platform gating decision matrix in CLAUDE.md.
21 lines
560 B
TypeScript
21 lines
560 B
TypeScript
import { AppState } from "react-native";
|
|
import { isNative } from "@/constants/platform";
|
|
|
|
export function getIsAppActivelyVisible(appState: string = AppState.currentState): boolean {
|
|
if (appState !== "active") {
|
|
return false;
|
|
}
|
|
|
|
if (isNative) {
|
|
return true;
|
|
}
|
|
|
|
const documentVisible = typeof document === "undefined" || document.visibilityState === "visible";
|
|
const windowFocused =
|
|
typeof document === "undefined" ||
|
|
typeof document.hasFocus !== "function" ||
|
|
document.hasFocus();
|
|
|
|
return documentVisible && windowFocused;
|
|
}
|