diff --git a/apps/renderer/src/modules/entry-column/Items/index.ts b/apps/renderer/src/modules/entry-column/Items/index.ts index 97c29bb8e..761728a30 100644 --- a/apps/renderer/src/modules/entry-column/Items/index.ts +++ b/apps/renderer/src/modules/entry-column/Items/index.ts @@ -1,19 +1,11 @@ import { FeedViewType } from "@follow/constants" -import { ArticleItem, ArticleItemSkeleton, ArticleItemStateLess } from "./article-item" -import { AudioItem, AudioItemSkeleton, AudioItemStateLess } from "./audio-item" -import { - NotificationItem, - NotificationItemSkeleton, - NotificationItemStateLess, -} from "./notification-item" -import { PictureItem, PictureItemSkeleton, PictureItemStateLess } from "./picture-item" -import { - SocialMediaItem, - SocialMediaItemSkeleton, - SocialMediaItemStateLess, -} from "./social-media-item" -import { VideoItem, VideoItemSkeleton, VideoItemStateLess } from "./video-item" +import { ArticleItem, ArticleItemSkeleton } from "./article-item" +import { AudioItem, AudioItemSkeleton } from "./audio-item" +import { NotificationItem, NotificationItemSkeleton } from "./notification-item" +import { PictureItem, PictureItemSkeleton } from "./picture-item" +import { SocialMediaItem, SocialMediaItemSkeleton } from "./social-media-item" +import { VideoItem, VideoItemSkeleton } from "./video-item" const ItemMap = { [FeedViewType.Articles]: ArticleItem, @@ -27,19 +19,6 @@ export const getItemComponentByView = (view: FeedViewType) => { return ItemMap[view] || ArticleItem } -const StatelessItemMap = { - [FeedViewType.Articles]: ArticleItemStateLess, - [FeedViewType.SocialMedia]: SocialMediaItemStateLess, - [FeedViewType.Pictures]: PictureItemStateLess, - [FeedViewType.Videos]: VideoItemStateLess, - [FeedViewType.Audios]: AudioItemStateLess, - [FeedViewType.Notifications]: NotificationItemStateLess, -} - -export const getStatelessItemComponentByView = (view: FeedViewType) => { - return StatelessItemMap[view] || ArticleItemStateLess -} - const SkeletonItemMap = { [FeedViewType.Articles]: ArticleItemSkeleton, [FeedViewType.SocialMedia]: SocialMediaItemSkeleton, diff --git a/apps/renderer/src/modules/entry-column/Items/picture-item-stateless.tsx b/apps/renderer/src/modules/entry-column/Items/picture-item-stateless.tsx new file mode 100644 index 000000000..a7bd97304 --- /dev/null +++ b/apps/renderer/src/modules/entry-column/Items/picture-item-stateless.tsx @@ -0,0 +1,60 @@ +import { Skeleton } from "@follow/components/ui/skeleton/index.jsx" +import { cn } from "@follow/utils/utils" + +import { RelativeTime } from "~/components/ui/datetime" +import { Media } from "~/components/ui/media" +import { FeedIcon } from "~/modules/feed/feed-icon" +import { FeedTitle } from "~/modules/feed/feed-title" + +import type { EntryItemStatelessProps } from "../types" + +export function PictureItemStateLess({ entry, feed }: EntryItemStatelessProps) { + return ( +
+
+
+
+
+ {entry.media?.[0] ? ( + + ) : ( + + )} +
+
+
+
+ {entry.title} +
+
+ + + · + {!!entry.publishedAt && } +
+
+
+
+
+ ) +} diff --git a/apps/renderer/src/modules/entry-column/Items/picture-item.tsx b/apps/renderer/src/modules/entry-column/Items/picture-item.tsx index 48e128054..1388e0fca 100644 --- a/apps/renderer/src/modules/entry-column/Items/picture-item.tsx +++ b/apps/renderer/src/modules/entry-column/Items/picture-item.tsx @@ -12,22 +12,18 @@ import type { PropsWithChildren } from "react" import { memo, useContext, useEffect, useMemo, useState } from "react" import { useTranslation } from "react-i18next" -import { RelativeTime } from "~/components/ui/datetime" -import { Media } from "~/components/ui/media" import { SwipeMedia } from "~/components/ui/media/SwipeMedia" import { ReactVirtuosoItemPlaceholder } from "~/components/ui/placeholder" import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams" import { filterSmallMedia } from "~/lib/utils" import { EntryContent } from "~/modules/entry-content" -import { FeedIcon } from "~/modules/feed/feed-icon" -import { FeedTitle } from "~/modules/feed/feed-title" import { useEntry } from "~/store/entry/hooks" import { useImageDimensions } from "~/store/image" import { usePreviewMedia } from "../../../components/ui/media/hooks" import { EntryItemWrapper } from "../layouts/EntryItemWrapper" import { GridItem, GridItemFooter } from "../templates/grid-item-template" -import type { EntryItemStatelessProps, UniversalItemProps } from "../types" +import type { UniversalItemProps } from "../types" export function PictureItem({ entryId, entryPreview, translation }: UniversalItemProps) { const entry = useEntry(entryId) || entryPreview @@ -205,57 +201,6 @@ const MasonryItemFixedDimensionWrapper = ( ) } -export function PictureItemStateLess({ entry, feed }: EntryItemStatelessProps) { - return ( -
-
-
-
-
- {entry.media?.[0] ? ( - - ) : ( - - )} -
-
-
-
- {entry.title} -
-
- - - · - {!!entry.publishedAt && } -
-
-
-
-
- ) -} - export const PictureItemSkeleton = (
diff --git a/apps/renderer/src/modules/entry-column/item-stateless.tsx b/apps/renderer/src/modules/entry-column/item-stateless.tsx new file mode 100644 index 000000000..cbd096eb5 --- /dev/null +++ b/apps/renderer/src/modules/entry-column/item-stateless.tsx @@ -0,0 +1,30 @@ +import { FeedViewType } from "@follow/constants" +import type { FC } from "react" +import { memo } from "react" + +import { ArticleItemStateLess } from "./Items/article-item" +import { AudioItemStateLess } from "./Items/audio-item" +import { NotificationItemStateLess } from "./Items/notification-item" +import { PictureItemStateLess } from "./Items/picture-item-stateless" +import { SocialMediaItemStateLess } from "./Items/social-media-item" +import { VideoItemStateLess } from "./Items/video-item" +import type { EntryItemStatelessProps } from "./types" + +const StatelessItemMap = { + [FeedViewType.Articles]: ArticleItemStateLess, + [FeedViewType.SocialMedia]: SocialMediaItemStateLess, + [FeedViewType.Pictures]: PictureItemStateLess, + [FeedViewType.Videos]: VideoItemStateLess, + [FeedViewType.Audios]: AudioItemStateLess, + [FeedViewType.Notifications]: NotificationItemStateLess, +} + +const getStatelessItemComponentByView = (view: FeedViewType) => { + return StatelessItemMap[view] || ArticleItemStateLess +} + +export const EntryItemStateless: FC = memo((props) => { + const Item = getStatelessItemComponentByView(props.view as FeedViewType) + + return +}) diff --git a/apps/renderer/src/modules/entry-column/item.tsx b/apps/renderer/src/modules/entry-column/item.tsx index 4c622fa92..9fd7a405f 100644 --- a/apps/renderer/src/modules/entry-column/item.tsx +++ b/apps/renderer/src/modules/entry-column/item.tsx @@ -11,14 +11,10 @@ import type { FlatEntryModel } from "~/store/entry" import { useEntry } from "~/store/entry/hooks" import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder" -import { - getItemComponentByView, - getSkeletonItemComponentByView, - getStatelessItemComponentByView, -} from "./Items" +import { getItemComponentByView, getSkeletonItemComponentByView } from "./Items" import { EntryItemWrapper } from "./layouts/EntryItemWrapper" import { girdClassNames } from "./styles" -import type { EntryItemStatelessProps, EntryListItemFC } from "./types" +import type { EntryListItemFC } from "./types" interface EntryItemProps { entryId: string @@ -57,12 +53,6 @@ export const EntryItem: FC = memo(({ entryId, view }) => { return }) -export const EntryItemStateless: FC = memo((props) => { - const Item = getStatelessItemComponentByView(props.view as FeedViewType) - - return -}) - const LoadingCircleFallback = (
diff --git a/apps/renderer/src/modules/shared/ViewSelectorRadioGroup.tsx b/apps/renderer/src/modules/shared/ViewSelectorRadioGroup.tsx index a6219cce3..e84a7d637 100644 --- a/apps/renderer/src/modules/shared/ViewSelectorRadioGroup.tsx +++ b/apps/renderer/src/modules/shared/ViewSelectorRadioGroup.tsx @@ -6,7 +6,7 @@ import { cloneElement, forwardRef } from "react" import { useI18n } from "~/hooks/common" -import { EntryItemStateless } from "../entry-column/item" +import { EntryItemStateless } from "../entry-column/item-stateless" export const ViewSelectorRadioGroup = forwardRef< HTMLInputElement,