chore: fix linter
This commit is contained in:
parent
e268a1fe9c
commit
15646a8989
6 changed files with 5 additions and 53 deletions
|
|
@ -54,9 +54,7 @@ const MemoEditorImpl: React.FC<MemoEditorProps> = ({
|
||||||
const { userGeneralSetting } = useAuth();
|
const { userGeneralSetting } = useAuth();
|
||||||
|
|
||||||
// Get default visibility from user settings
|
// Get default visibility from user settings
|
||||||
const defaultVisibility = userGeneralSetting?.memoVisibility
|
const defaultVisibility = userGeneralSetting?.memoVisibility ? convertVisibilityFromString(userGeneralSetting.memoVisibility) : undefined;
|
||||||
? convertVisibilityFromString(userGeneralSetting.memoVisibility)
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
useMemoInit(editorRef, memoName, cacheKey, currentUser?.name ?? "", autoFocus, defaultVisibility);
|
useMemoInit(editorRef, memoName, cacheKey, currentUser?.name ?? "", autoFocus, defaultVisibility);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import type { Attachment } from "@/types/proto/api/v1/attachment_service_pb";
|
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 {
|
interface AttachmentCardProps {
|
||||||
attachment: Attachment;
|
attachment: Attachment;
|
||||||
|
|
@ -25,14 +25,7 @@ const AttachmentCard = ({ attachment, onClick, className }: AttachmentCardProps)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachmentType === "video/*") {
|
if (attachmentType === "video/*") {
|
||||||
return (
|
return <video src={sourceUrl} className={cn("w-full h-full object-cover rounded-lg", className)} controls preload="metadata" />;
|
||||||
<video
|
|
||||||
src={sourceUrl}
|
|
||||||
className={cn("w-full h-full object-cover rounded-lg", className)}
|
|
||||||
controls
|
|
||||||
preload="metadata"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,6 @@ const AttachmentList = ({ attachments }: AttachmentListProps) => {
|
||||||
onOpenChange={(open: boolean) => setPreviewImage((prev) => ({ ...prev, open }))}
|
onOpenChange={(open: boolean) => setPreviewImage((prev) => ({ ...prev, open }))}
|
||||||
imgUrls={previewImage.urls}
|
imgUrls={previewImage.urls}
|
||||||
initialIndex={previewImage.index}
|
initialIndex={previewImage.index}
|
||||||
mimeType={previewImage.mimeType}
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,16 @@ import { X } from "lucide-react";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Dialog, DialogContent } from "@/components/ui/dialog";
|
import { Dialog, DialogContent } from "@/components/ui/dialog";
|
||||||
import { getColorspace } from "@/utils/attachment";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
imgUrls: string[];
|
imgUrls: string[];
|
||||||
initialIndex?: number;
|
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 [currentIndex, setCurrentIndex] = useState(initialIndex);
|
||||||
const colorspace = mimeType ? getColorspace(mimeType) : undefined;
|
|
||||||
|
|
||||||
// Update current index when initialIndex prop changes
|
// Update current index when initialIndex prop changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -83,7 +80,6 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls, initialIndex = 0, mim
|
||||||
draggable={false}
|
draggable={false}
|
||||||
loading="eager"
|
loading="eager"
|
||||||
decoding="async"
|
decoding="async"
|
||||||
{...(colorspace && { colorSpace: colorspace as unknown as string })}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,10 +82,7 @@ const PreferencesSection = () => {
|
||||||
|
|
||||||
<SettingGroup title={t("setting.preference")} showSeparator>
|
<SettingGroup title={t("setting.preference")} showSeparator>
|
||||||
<SettingRow label={t("setting.preference-section.default-memo-visibility")}>
|
<SettingRow label={t("setting.preference-section.default-memo-visibility")}>
|
||||||
<Select
|
<Select value={setting.memoVisibility || "PRIVATE"} onValueChange={handleDefaultMemoVisibilityChanged}>
|
||||||
value={setting.memoVisibility || "PRIVATE"}
|
|
||||||
onValueChange={handleDefaultMemoVisibilityChanged}
|
|
||||||
>
|
|
||||||
<SelectTrigger className="min-w-fit">
|
<SelectTrigger className="min-w-fit">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<VisibilityIcon visibility={convertVisibilityFromString(setting.memoVisibility)} />
|
<VisibilityIcon visibility={convertVisibilityFromString(setting.memoVisibility)} />
|
||||||
|
|
|
||||||
|
|
@ -52,34 +52,3 @@ export const isMidiFile = (mimeType: string): boolean => {
|
||||||
const isPSD = (t: string) => {
|
const isPSD = (t: string) => {
|
||||||
return t === "image/vnd.adobe.photoshop" || t === "image/x-photoshop" || t === "image/photoshop";
|
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)");
|
|
||||||
};
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue