mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
Move
This commit is contained in:
parent
ea46ac0196
commit
b5eaa757da
@ -3,7 +3,7 @@ import { EnteFile } from "@/new/photos/types/file";
|
||||
import {
|
||||
LoadingThumbnail,
|
||||
StaticThumbnail,
|
||||
} from "components/PlaceholderThumbnails";
|
||||
} from "@/new/photos/components/PlaceholderThumbnails";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export default function CollectionCard(props: {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { assertionFailed } from "@/base/assert";
|
||||
import { useIsMobileWidth } from "@/base/hooks";
|
||||
import { FileType } from "@/media/file-type";
|
||||
import { ItemCard } from "@/new/photos/components/ItemCards";
|
||||
import {
|
||||
isMLSupported,
|
||||
mlStatusSnapshot,
|
||||
@ -37,7 +38,6 @@ import {
|
||||
useTheme,
|
||||
type Theme,
|
||||
} from "@mui/material";
|
||||
import CollectionCard from "components/Collections/CollectionCard";
|
||||
import { ResultPreviewTile } from "components/Collections/styledComponents";
|
||||
import { t } from "i18next";
|
||||
import pDebounce from "p-debounce";
|
||||
@ -580,11 +580,10 @@ const OptionContents = ({ data }: { data: SearchOption }) => (
|
||||
|
||||
<Stack direction={"row"} gap={1}>
|
||||
{data.previewFiles.map((file) => (
|
||||
<CollectionCard
|
||||
<ItemCard
|
||||
key={file.id}
|
||||
coverFile={file}
|
||||
onClick={() => null}
|
||||
collectionTile={ResultPreviewTile}
|
||||
TileComponent={ResultPreviewTile}
|
||||
/>
|
||||
))}
|
||||
</Stack>
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
import {
|
||||
LoadingThumbnail,
|
||||
StaticThumbnail,
|
||||
} from "components/PlaceholderThumbnails";
|
||||
} from "@/new/photos/components/PlaceholderThumbnails";
|
||||
import i18n from "i18next";
|
||||
import { DeduplicateContext } from "pages/deduplicate";
|
||||
import { GalleryContext } from "pages/gallery";
|
||||
|
43
web/packages/new/photos/components/ItemCards.tsx
Normal file
43
web/packages/new/photos/components/ItemCards.tsx
Normal file
@ -0,0 +1,43 @@
|
||||
import {
|
||||
LoadingThumbnail,
|
||||
StaticThumbnail,
|
||||
} from "@/new/photos/components/PlaceholderThumbnails";
|
||||
import downloadManager from "@/new/photos/services/download";
|
||||
import { type EnteFile } from "@/new/photos/types/file";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
interface ItemCardProps {
|
||||
coverFile: EnteFile;
|
||||
TileComponent: React.FC<React.PropsWithChildren>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A simplified variant of {@link CollectionCard}, meant to be used for
|
||||
* representing either collections and files.
|
||||
*/
|
||||
export const ItemCard: React.FC<ItemCardProps> = ({
|
||||
coverFile,
|
||||
TileComponent,
|
||||
}) => {
|
||||
const [coverImageURL, setCoverImageURL] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
const main = async () => {
|
||||
const url = await downloadManager.getThumbnailForPreview(coverFile);
|
||||
if (url) setCoverImageURL(url);
|
||||
};
|
||||
void main();
|
||||
}, [coverFile]);
|
||||
|
||||
return (
|
||||
<TileComponent>
|
||||
{coverFile.metadata.hasStaticThumbnail ? (
|
||||
<StaticThumbnail fileType={coverFile.metadata.fileType} />
|
||||
) : coverImageURL ? (
|
||||
<img src={coverImageURL} />
|
||||
) : (
|
||||
<LoadingThumbnail />
|
||||
)}
|
||||
</TileComponent>
|
||||
);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user