@@ -1,13 +1,13 @@
|
||||
import { FeedViewType } from "~/lib/enum"
|
||||
|
||||
import { ArticleItem } from "./article-item"
|
||||
import { AudioItem } from "./audio-item"
|
||||
import { NotificationItem } from "./notification-item"
|
||||
import { PictureItem } from "./picture-item"
|
||||
import { SocialMediaItem } from "./social-media-item"
|
||||
import { VideoItem } 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 map = {
|
||||
const ItemMap = {
|
||||
[FeedViewType.Articles]: ArticleItem,
|
||||
[FeedViewType.SocialMedia]: SocialMediaItem,
|
||||
[FeedViewType.Pictures]: PictureItem,
|
||||
@@ -16,5 +16,18 @@ const map = {
|
||||
[FeedViewType.Notifications]: NotificationItem,
|
||||
}
|
||||
export const getItemComponentByView = (view: FeedViewType) => {
|
||||
return map[view] || ArticleItem
|
||||
return ItemMap[view] || ArticleItem
|
||||
}
|
||||
|
||||
const SkeletonItemMap = {
|
||||
[FeedViewType.Articles]: ArticleItemSkeleton,
|
||||
[FeedViewType.SocialMedia]: SocialMediaItemSkeleton,
|
||||
[FeedViewType.Pictures]: PictureItemSkeleton,
|
||||
[FeedViewType.Videos]: VideoItemSkeleton,
|
||||
[FeedViewType.Audios]: AudioItemSkeleton,
|
||||
[FeedViewType.Notifications]: NotificationItemSkeleton,
|
||||
}
|
||||
|
||||
export const getSkeletonItemComponentByView = (view: FeedViewType) => {
|
||||
return SkeletonItemMap[view]
|
||||
}
|
||||
|
||||
@@ -4,20 +4,14 @@ import { memo } from "react"
|
||||
import { LoadingCircle } from "~/components/ui/loading"
|
||||
import { views } from "~/constants"
|
||||
import { useAuthQuery } from "~/hooks/common"
|
||||
import { FeedViewType } from "~/lib/enum"
|
||||
import type { FeedViewType } from "~/lib/enum"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { Queries } from "~/queries"
|
||||
import type { FlatEntryModel } from "~/store/entry"
|
||||
import { useEntry } from "~/store/entry/hooks"
|
||||
|
||||
import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder"
|
||||
import { getItemComponentByView } from "./Items"
|
||||
import { ArticleItemSkeleton } from "./Items/article-item"
|
||||
import { AudioItemSkeleton } from "./Items/audio-item"
|
||||
import { NotificationItemSkeleton } from "./Items/notification-item"
|
||||
import { PictureItemSkeleton } from "./Items/picture-item"
|
||||
import { SocialMediaItemSkeleton } from "./Items/social-media-item"
|
||||
import { VideoItemSkeleton } from "./Items/video-item"
|
||||
import { getItemComponentByView, getSkeletonItemComponentByView } from "./Items"
|
||||
import { EntryItemWrapper } from "./layouts/EntryItemWrapper"
|
||||
import { girdClassNames } from "./styles"
|
||||
import type { EntryListItemFC } from "./types"
|
||||
@@ -58,15 +52,6 @@ export const EntryItem: FC<EntryItemProps> = memo(({ entryId, view }) => {
|
||||
return <EntryItemImpl entry={entry} view={view} />
|
||||
})
|
||||
|
||||
const SkeletonItemMap = {
|
||||
[FeedViewType.Articles]: ArticleItemSkeleton,
|
||||
[FeedViewType.SocialMedia]: SocialMediaItemSkeleton,
|
||||
[FeedViewType.Pictures]: PictureItemSkeleton,
|
||||
[FeedViewType.Videos]: VideoItemSkeleton,
|
||||
[FeedViewType.Audios]: AudioItemSkeleton,
|
||||
[FeedViewType.Notifications]: NotificationItemSkeleton,
|
||||
}
|
||||
|
||||
const LoadingCircleFallback = (
|
||||
<div className="center mt-2">
|
||||
<LoadingCircle size="medium" />
|
||||
@@ -77,7 +62,7 @@ export const EntryItemSkeleton: FC<{
|
||||
view: FeedViewType
|
||||
count?: number
|
||||
}> = memo(({ view, count }) => {
|
||||
const SkeletonItem = SkeletonItemMap[view]
|
||||
const SkeletonItem = getSkeletonItemComponentByView(view)
|
||||
if (count === 1) {
|
||||
return SkeletonItem
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user