Centralize platform gating and fix iPad/tablet support
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.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Asset } from "expo-asset";
|
||||
import { Platform } from "react-native";
|
||||
import { getDesktopHost } from "@/desktop/host";
|
||||
import { buildNotificationRoute, resolveNotificationTarget } from "./notification-routing";
|
||||
import { isNative } from "@/constants/platform";
|
||||
|
||||
type OsNotificationPayload = {
|
||||
title: string;
|
||||
@@ -80,7 +80,7 @@ async function ensureNotificationPermission(): Promise<boolean> {
|
||||
}
|
||||
|
||||
export async function ensureOsNotificationPermission(): Promise<boolean> {
|
||||
if (Platform.OS !== "web") {
|
||||
if (isNative) {
|
||||
return false;
|
||||
}
|
||||
return await ensureNotificationPermission();
|
||||
@@ -154,7 +154,7 @@ function attachWebClickHandler(
|
||||
|
||||
export async function sendOsNotification(payload: OsNotificationPayload): Promise<boolean> {
|
||||
// Mobile/native notifications should be remote push only.
|
||||
if (Platform.OS !== "web") {
|
||||
if (isNative) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user