diff --git a/frontend/lib/dom/comment.ts b/frontend/lib/dom/comment.ts index 84c827c1..a690ce91 100644 --- a/frontend/lib/dom/comment.ts +++ b/frontend/lib/dom/comment.ts @@ -6,7 +6,7 @@ import iconInfoOutlineRounded from "iconify/info-outline-rounded"; import { Comment } from "../types"; import { getJWT, decodeJWT, logout, fetchGitHubMeta } from "../auth"; import { apiEndpoint } from "../const"; -import { groupBy, dateTimeFormatter, isReallyMobile } from "../util"; +import { groupBy, dateTimeFormatter, isMobileLike } from "../util"; let selectedOffset: HTMLElement | null = null; @@ -124,7 +124,7 @@ export const selectOffsetParagraph = async ({ } if ( - (!isReallyMobile() && selectedOffset?.dataset.reviewHasComments) || + (!isMobileLike() && selectedOffset?.dataset.reviewHasComments) || forceOpenCommentsPanel ) { delete selectedOffset.dataset.reviewFocused; diff --git a/frontend/lib/util.ts b/frontend/lib/util.ts index 92d3dd5c..56c1382f 100644 --- a/frontend/lib/util.ts +++ b/frontend/lib/util.ts @@ -18,8 +18,6 @@ export const dateTimeFormatter = new Intl.DateTimeFormat("zh-CN", { timeStyle: "short", }); -export function isReallyMobile() { - return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( - navigator.userAgent, - ); +export function isMobileLike() { + return window.innerWidth < 768; }