chore: fix linter

This commit is contained in:
Steven 2026-01-05 21:57:07 +08:00
parent e268a1fe9c
commit 15646a8989
6 changed files with 5 additions and 53 deletions

View File

@ -54,9 +54,7 @@ const MemoEditorImpl: React.FC<MemoEditorProps> = ({
const { userGeneralSetting } = useAuth();
// Get default visibility from user settings
const defaultVisibility = userGeneralSetting?.memoVisibility
? convertVisibilityFromString(userGeneralSetting.memoVisibility)
: undefined;
const defaultVisibility = userGeneralSetting?.memoVisibility ? convertVisibilityFromString(userGeneralSetting.memoVisibility) : undefined;
useMemoInit(editorRef, memoName, cacheKey, currentUser?.name ?? "", autoFocus, defaultVisibility);

View File

@ -1,6 +1,6 @@
import { cn } from "@/lib/utils";
import type { Attachment } from "@/types/proto/api/v1/attachment_service_pb";
import { getAttachmentType, getAttachmentUrl, getColorspace } from "@/utils/attachment";
import { getAttachmentType, getAttachmentUrl } from "@/utils/attachment";
interface AttachmentCardProps {
attachment: Attachment;
@ -25,14 +25,7 @@ const AttachmentCard = ({ attachment, onClick, className }: AttachmentCardProps)
}
if (attachmentType === "video/*") {
return (
<video
src={sourceUrl}
className={cn("w-full h-full object-cover rounded-lg", className)}
controls
preload="metadata"
/>
);
return <video src={sourceUrl} className={cn("w-full h-full object-cover rounded-lg", className)} controls preload="metadata" />;
}
return null;

View File

@ -131,7 +131,6 @@ const AttachmentList = ({ attachments }: AttachmentListProps) => {
onOpenChange={(open: boolean) => setPreviewImage((prev) => ({ ...prev, open }))}
imgUrls={previewImage.urls}
initialIndex={previewImage.index}
mimeType={previewImage.mimeType}
/>
</>
);

View File

@ -2,19 +2,16 @@ import { X } from "lucide-react";
import React, { useEffect, useState } from "react";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent } from "@/components/ui/dialog";
import { getColorspace } from "@/utils/attachment";
interface Props {
open: boolean;
onOpenChange: (open: boolean) => void;
imgUrls: string[];
initialIndex?: number;
mimeType?: string; // MIME type for HDR detection
}
function PreviewImageDialog({ open, onOpenChange, imgUrls, initialIndex = 0, mimeType }: Props) {
function PreviewImageDialog({ open, onOpenChange, imgUrls, initialIndex = 0 }: Props) {
const [currentIndex, setCurrentIndex] = useState(initialIndex);
const colorspace = mimeType ? getColorspace(mimeType) : undefined;
// Update current index when initialIndex prop changes
useEffect(() => {
@ -83,7 +80,6 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls, initialIndex = 0, mim
draggable={false}
loading="eager"
decoding="async"
{...(colorspace && { colorSpace: colorspace as unknown as string })}
/>
</div>

View File

@ -82,10 +82,7 @@ const PreferencesSection = () => {
<SettingGroup title={t("setting.preference")} showSeparator>
<SettingRow label={t("setting.preference-section.default-memo-visibility")}>
<Select
value={setting.memoVisibility || "PRIVATE"}
onValueChange={handleDefaultMemoVisibilityChanged}
>
<Select value={setting.memoVisibility || "PRIVATE"} onValueChange={handleDefaultMemoVisibilityChanged}>
<SelectTrigger className="min-w-fit">
<div className="flex items-center gap-2">
<VisibilityIcon visibility={convertVisibilityFromString(setting.memoVisibility)} />

View File

@ -52,34 +52,3 @@ export const isMidiFile = (mimeType: string): boolean => {
const isPSD = (t: string) => {
return t === "image/vnd.adobe.photoshop" || t === "image/x-photoshop" || t === "image/photoshop";
};
// HDR-capable MIME types that support wide color gamut
export const HDR_CAPABLE_FORMATS = [
"image/heic",
"image/heif",
"image/webp",
"image/png", // PNG can contain ICC profiles for wide gamut
"image/jpeg", // JPEG can support extended color via profiles
"video/mp4", // Can contain HDR tracks
"video/quicktime", // Can contain HDR tracks
"video/x-matroska", // Can contain HDR tracks
"video/webm", // VP9 Profile 2 for HDR
];
// isHDRCapable returns true if the MIME type supports HDR/wide color gamut.
export const isHDRCapable = (mimeType: string): boolean => {
return HDR_CAPABLE_FORMATS.some((format) => mimeType.startsWith(format));
};
// getColorspace returns the appropriate colorspace attribute for wide gamut images.
// Returns "display-p3" for HDR-capable formats, undefined for standard images.
export const getColorspace = (mimeType: string): string | undefined => {
return isHDRCapable(mimeType) ? "display-p3" : undefined;
};
// supportsHDR checks if the browser supports wide color gamut display.
// Uses CSS.supports() to detect color-gamut capability.
export const supportsHDR = (): boolean => {
if (typeof CSS === "undefined") return false;
return CSS.supports("(color-gamut: srgb)") && CSS.supports("(color-gamut: p3)");
};