Skip to content

Commit

Permalink
refactor: isReallyMobile -> isMobileLike
Browse files Browse the repository at this point in the history
  • Loading branch information
shaokeyibb committed Oct 7, 2024
1 parent 355de04 commit 4437876
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions frontend/lib/dom/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -124,7 +124,7 @@ export const selectOffsetParagraph = async ({
}

if (
(!isReallyMobile() && selectedOffset?.dataset.reviewHasComments) ||
(!isMobileLike() && selectedOffset?.dataset.reviewHasComments) ||
forceOpenCommentsPanel
) {
delete selectedOffset.dataset.reviewFocused;
Expand Down
6 changes: 2 additions & 4 deletions frontend/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 4437876

Please sign in to comment.