fix: do not hide refresh button for star list

This commit is contained in:
Stephen Zhou 2025-07-21 17:35:00 +08:00
parent f67c0d0359
commit b11e7e9a36
No known key found for this signature in database
3 changed files with 41 additions and 27 deletions

View File

@ -44,12 +44,14 @@ const category: CommandCategory = "category.entry"
const useCollect = () => {
const { t } = useTranslation()
return useMutation({
mutationFn: async ({ entryId, view }: { entryId: string; view: FeedViewType }) =>
collectionSyncService.starEntry({
mutationFn: async ({ entryId, view }: { entryId: string; view: FeedViewType }) => {
const { isCollection } = getRouteParams()
return collectionSyncService.starEntry({
entryId,
view,
}),
invalidate: !isCollection,
})
},
onSuccess: () => {
toast.success(t("entry_actions.starred"), {
duration: 1000,

View File

@ -16,7 +16,7 @@ import { useNavigate } from "react-router"
import { previewBackPath } from "~/atoms/preview"
import { useGeneralSettingKey } from "~/atoms/settings/general"
import { useTimelineColumnShow } from "~/atoms/sidebar"
import { FEED_COLLECTION_LIST, ROUTE_ENTRY_PENDING } from "~/constants"
import { ROUTE_ENTRY_PENDING } from "~/constants"
import { useFollow } from "~/hooks/biz/useFollow"
import { getRouteParams, useRouteParams } from "~/hooks/biz/useRouteParams"
import { COMMAND_ID } from "~/modules/command/commands/id"
@ -43,13 +43,11 @@ export const EntryListHeader: FC<{
const unreadOnly = useGeneralSettingKey("unreadOnly")
const { feedId, entryId, view } = routerParams
const { feedId, entryId, view, isCollection } = routerParams
const isPreview = useIsPreviewFeed()
const headerTitle = useFeedHeaderTitle()
const isInCollectionList = feedId === FEED_COLLECTION_LIST
const titleInfo = !!headerTitle && (
<div className="flex min-w-0 items-center break-all text-lg font-bold leading-tight">
<EllipsisHorizontalTextWithTooltip className="inline-block !w-auto max-w-full">
@ -83,7 +81,7 @@ export const EntryListHeader: FC<{
<div
className={cn(
"text-text-secondary relative z-[1] flex items-center gap-1 self-baseline",
(isInCollectionList || !headerTitle) && "opacity-0 [&_*]:!pointer-events-none",
!headerTitle && "opacity-0 [&_*]:!pointer-events-none",
"translate-x-[6px]",
)}
@ -131,22 +129,26 @@ export const EntryListHeader: FC<{
/>
</ActionButton>
))}
<ActionButton
tooltip={
!unreadOnly
? t("entry_list_header.show_unread_only")
: t("entry_list_header.show_all")
}
shortcut={commandShortcuts[COMMAND_ID.timeline.unreadOnly]}
onClick={() => runCmdFn(COMMAND_ID.timeline.unreadOnly, [!unreadOnly])()}
>
{unreadOnly ? (
<i className="i-mgc-round-cute-fi" />
) : (
<i className="i-mgc-round-cute-re" />
)}
</ActionButton>
<MarkAllReadButton shortcut />
{!isCollection && (
<>
<ActionButton
tooltip={
!unreadOnly
? t("entry_list_header.show_unread_only")
: t("entry_list_header.show_all")
}
shortcut={commandShortcuts[COMMAND_ID.timeline.unreadOnly]}
onClick={() => runCmdFn(COMMAND_ID.timeline.unreadOnly, [!unreadOnly])()}
>
{unreadOnly ? (
<i className="i-mgc-round-cute-fi" />
) : (
<i className="i-mgc-round-cute-re" />
)}
</ActionButton>
<MarkAllReadButton shortcut />
</>
)}
</div>
)}
</div>

View File

@ -24,7 +24,15 @@ const get = useCollectionStore.getState
const set = useCollectionStore.setState
class CollectionSyncService {
async starEntry({ entryId, view }: { entryId: string; view: FeedViewType }) {
async starEntry({
entryId,
view,
invalidate,
}: {
entryId: string
view: FeedViewType
invalidate?: boolean
}) {
const entry = getEntry(entryId)
if (!entry) {
return
@ -54,7 +62,9 @@ class CollectionSyncService {
await tx.run()
invalidateEntriesQuery({ collection: true })
if (invalidate) {
invalidateEntriesQuery({ collection: true })
}
}
async unstarEntry({ entryId, invalidate = true }: { entryId: string; invalidate?: boolean }) {