refactor: update feed selection logic
This commit is contained in:
@@ -16,9 +16,12 @@ import {
|
||||
useEntry,
|
||||
useEntryIdsByCategory,
|
||||
useEntryIdsByFeedId,
|
||||
useEntryIdsByInboxId,
|
||||
useEntryIdsByView,
|
||||
} from "@/src/store/entry/hooks"
|
||||
import { FEED_COLLECTION_LIST } from "@/src/store/entry/utils"
|
||||
import { useFeed } from "@/src/store/feed/hooks"
|
||||
import { useInbox } from "@/src/store/inbox/hooks"
|
||||
import { useList } from "@/src/store/list/hooks"
|
||||
|
||||
import { LeftAction, RightAction } from "./action"
|
||||
@@ -49,9 +52,9 @@ export function EntryList() {
|
||||
case "list": {
|
||||
return <ListEntryList listId={selectedFeed.listId} />
|
||||
}
|
||||
// case "inbox": {
|
||||
// return <InboxEntryList inboxId={selectedFeed.inboxId} />
|
||||
// }
|
||||
case "inbox": {
|
||||
return <InboxEntryList inboxId={selectedFeed.inboxId} />
|
||||
}
|
||||
// No default
|
||||
}
|
||||
}
|
||||
@@ -65,7 +68,8 @@ function ViewEntryList({ viewId }: { viewId: FeedViewType }) {
|
||||
function FeedEntryList({ feedId }: { feedId: string }) {
|
||||
const feed = useFeed(feedId)
|
||||
const entryIds = useEntryIdsByFeedId(feedId)
|
||||
return <EntryListScreen title={feed?.title ?? ""} entryIds={entryIds} />
|
||||
const title = feedId === FEED_COLLECTION_LIST ? "Collections" : (feed?.title ?? "")
|
||||
return <EntryListScreen title={title} entryIds={entryIds} />
|
||||
}
|
||||
|
||||
function CategoryEntryList({ categoryName }: { categoryName: string }) {
|
||||
@@ -76,10 +80,15 @@ function CategoryEntryList({ categoryName }: { categoryName: string }) {
|
||||
function ListEntryList({ listId }: { listId: string }) {
|
||||
const list = useList(listId)
|
||||
if (!list) return null
|
||||
|
||||
return <EntryListScreen title={list.title} entryIds={list.entryIds ?? []} />
|
||||
}
|
||||
|
||||
function InboxEntryList({ inboxId }: { inboxId: string }) {
|
||||
const inbox = useInbox(inboxId)
|
||||
const entryIds = useEntryIdsByInboxId(inboxId)
|
||||
return <EntryListScreen title={inbox?.title ?? "Inbox"} entryIds={entryIds} />
|
||||
}
|
||||
|
||||
function EntryListScreen({ title, entryIds }: { title: string; entryIds: string[] }) {
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -59,7 +59,7 @@ export function useSelectedCollection() {
|
||||
}
|
||||
export const selectCollection = (state: CollectionPanelState) => {
|
||||
jotaiStore.set(collectionPanelStateAtom, state)
|
||||
if (state.type === "view") {
|
||||
if (state.type === "view" || state.type === "list") {
|
||||
jotaiStore.set(selectedFeedAtom, state)
|
||||
}
|
||||
}
|
||||
@@ -83,6 +83,10 @@ export type SelectedFeed =
|
||||
type: "list"
|
||||
listId: string
|
||||
}
|
||||
| {
|
||||
type: "inbox"
|
||||
inboxId: string
|
||||
}
|
||||
|
||||
const selectedFeedAtom = atom<SelectedFeed>({
|
||||
type: "view",
|
||||
@@ -109,10 +113,10 @@ export function useSelectedFeed() {
|
||||
payload = { listId: selectedFeed.listId }
|
||||
break
|
||||
}
|
||||
// case "inbox": {
|
||||
// payload = { inboxId: selectedFeed.inboxId }
|
||||
// break
|
||||
// }
|
||||
case "inbox": {
|
||||
payload = { inboxId: selectedFeed.inboxId }
|
||||
break
|
||||
}
|
||||
// No default
|
||||
}
|
||||
usePrefetchEntries(payload)
|
||||
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
import { useCurrentView, useFeedListSortMethod, useFeedListSortOrder } from "../subscription/atoms"
|
||||
import { ViewPageCurrentViewProvider } from "../subscription/ctx"
|
||||
import { SubscriptionList } from "../subscription/SubscriptionLists"
|
||||
import { selectFeed, useSelectedCollection } from "./atoms"
|
||||
import { closeDrawer, selectFeed, useSelectedCollection } from "./atoms"
|
||||
import { ListHeaderComponent, ViewHeaderComponent } from "./header"
|
||||
|
||||
export const FeedPanel = () => {
|
||||
@@ -153,6 +153,7 @@ const CategoryGrouped = memo(
|
||||
type: "category",
|
||||
categoryName: category,
|
||||
})
|
||||
closeDrawer()
|
||||
}}
|
||||
className="h-12 flex-row items-center px-3"
|
||||
>
|
||||
@@ -229,6 +230,7 @@ const SubscriptionItem = memo(({ id, className }: { id: string; className?: stri
|
||||
type: "feed",
|
||||
feedId: id,
|
||||
})
|
||||
closeDrawer()
|
||||
}}
|
||||
>
|
||||
<View className="dark:border-tertiary-system-background mr-3 size-5 items-center justify-center overflow-hidden rounded-full border border-transparent dark:bg-[#222]">
|
||||
|
||||
@@ -11,6 +11,7 @@ import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { ItemPressable } from "@/src/components/ui/pressable/item-pressable"
|
||||
import { StarCuteFiIcon } from "@/src/icons/star_cute_fi"
|
||||
import { FEED_COLLECTION_LIST } from "@/src/store/entry/utils"
|
||||
import {
|
||||
useGroupedSubscription,
|
||||
useInboxSubscription,
|
||||
@@ -22,6 +23,7 @@ import {
|
||||
} from "@/src/store/subscription/hooks"
|
||||
import { subscriptionSyncService } from "@/src/store/subscription/store"
|
||||
|
||||
import { closeDrawer, selectFeed } from "../feed-drawer/atoms"
|
||||
import { useFeedListSortMethod, useFeedListSortOrder, viewAtom } from "./atoms"
|
||||
import { CategoryGrouped } from "./CategoryGrouped"
|
||||
import { ViewTabHeight } from "./constants"
|
||||
@@ -200,7 +202,8 @@ const StarItem = () => {
|
||||
return (
|
||||
<ItemPressable
|
||||
onPress={() => {
|
||||
// TODO
|
||||
selectFeed({ type: "feed", feedId: FEED_COLLECTION_LIST })
|
||||
closeDrawer()
|
||||
}}
|
||||
className="mt-4 h-12 w-full flex-row items-center px-3"
|
||||
>
|
||||
|
||||
@@ -9,6 +9,8 @@ import { useSubscription } from "@/src/store/subscription/hooks"
|
||||
import { getInboxStoreId } from "@/src/store/subscription/utils"
|
||||
import { useUnreadCount } from "@/src/store/unread/hooks"
|
||||
|
||||
import { closeDrawer, selectFeed } from "../../feed-drawer/atoms"
|
||||
|
||||
export const InboxItem = memo(({ id }: { id: string }) => {
|
||||
const subscription = useSubscription(getInboxStoreId(id))
|
||||
const unreadCount = useUnreadCount(id)
|
||||
@@ -16,7 +18,13 @@ export const InboxItem = memo(({ id }: { id: string }) => {
|
||||
if (!subscription) return null
|
||||
return (
|
||||
<Animated.View exiting={FadeOutUp}>
|
||||
<ItemPressable className="h-12 flex-row items-center px-3">
|
||||
<ItemPressable
|
||||
className="h-12 flex-row items-center px-3"
|
||||
onPress={() => {
|
||||
selectFeed({ type: "inbox", inboxId: id })
|
||||
closeDrawer()
|
||||
}}
|
||||
>
|
||||
<View className="ml-0.5 overflow-hidden rounded">
|
||||
<InboxCuteFiIcon
|
||||
height={20}
|
||||
|
||||
Reference in New Issue
Block a user