Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 201x 1x 1x 1x 1x 1x 1x | import { theme } from "theme";
export type ClientPlatform =
| "web_desktop"
| "web_mobile"
| "app_ios"
| "app_android";
// Matches the app's own "mobile" breakpoint (theme.breakpoints.down("md")).
function isMobileViewport(): boolean {
Iif (typeof window === "undefined" || !window.matchMedia) return false;
const query = theme.breakpoints.down("md").replace("@media ", "");
return window.matchMedia(query).matches;
}
// The client platform a request is coming from, or null when it can't be
// determined (e.g. during server-side rendering). Requests from web views inside
// the native app are reported as web_desktop/web_mobile based on viewport.
export function getClientPlatform(): ClientPlatform | null {
Iif (typeof window === "undefined" || !window.matchMedia) return null;
return isMobileViewport() ? "web_mobile" : "web_desktop";
}
|