Skip to content

Commit

Permalink
fix: feed title
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Feb 10, 2025
1 parent 5f2cf8f commit 848e998
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions apps/renderer/src/store/feed/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import type { FeedModel, FeedOrListRespModel, InboxModel, ListModel } from "@fol
import { useCallback } from "react"
import { useTranslation } from "react-i18next"

import { FEED_COLLECTION_LIST, ROUTE_FEED_IN_FOLDER, ROUTE_FEED_PENDING } from "~/constants"
import {
FEED_COLLECTION_LIST,
ROUTE_FEED_IN_FOLDER,
ROUTE_FEED_PENDING,
ROUTE_TIMELINE_OF_INBOX,
ROUTE_TIMELINE_OF_LIST,
} from "~/constants"
import { useRouteParams } from "~/hooks/biz/useRouteParams"

import { useInboxStore } from "../inbox"
Expand Down Expand Up @@ -71,12 +77,18 @@ export const useInboxByIdSelector = <T>(

export const useFeedHeaderTitle = () => {
const { t } = useTranslation()
const { feedId: currentFeedId, view, listId, inboxId } = useRouteParams()
const { feedId: currentFeedId, view, listId, inboxId, timelineId } = useRouteParams()

const listTitle = useListByIdSelector(listId, getPreferredTitle)
const inboxTitle = useInboxByIdSelector(inboxId, getPreferredTitle)
const feedTitle = useFeedByIdSelector(currentFeedId, getPreferredTitle)

if (timelineId?.startsWith(ROUTE_TIMELINE_OF_LIST)) {
return listTitle
} else if (timelineId?.startsWith(ROUTE_TIMELINE_OF_INBOX)) {
return inboxTitle
}

switch (currentFeedId) {
case ROUTE_FEED_PENDING: {
return t(views[view]!.name as any)
Expand All @@ -88,7 +100,7 @@ export const useFeedHeaderTitle = () => {
if (currentFeedId?.startsWith(ROUTE_FEED_IN_FOLDER)) {
return currentFeedId.replace(ROUTE_FEED_IN_FOLDER, "")
}
return feedTitle || listTitle || inboxTitle
return feedTitle
}
}
}

0 comments on commit 848e998

Please sign in to comment.