fix: allow collect entry from list

This commit is contained in:
Stephen Zhou
2024-11-19 16:45:29 +08:00
parent fcf775c976
commit 706f484757
7 changed files with 18 additions and 11 deletions
@@ -20,7 +20,8 @@ import { COMMAND_ID } from "./id"
const useCollect = () => {
const { t } = useTranslation()
return useMutation({
mutationFn: async (entryId: string) => entryActions.markStar(entryId, true),
mutationFn: async ({ entryId, view }: { entryId: string; view?: FeedViewType }) =>
entryActions.markStar(entryId, true, view),
onSuccess: () => {
toast.success(t("entry_actions.starred"), {
@@ -109,7 +110,7 @@ export const useRegisterEntryCommands = () => {
id: COMMAND_ID.entry.star,
label: t("entry_actions.star"),
icon: <i className="i-mgc-star-cute-re" />,
run: ({ entryId }) => {
run: ({ entryId, view }) => {
const entry = useEntryStore.getState().flatMapEntries[entryId]
if (!entry) {
toast.error("Failed to star: entry is not available", { duration: 3000 })
@@ -124,7 +125,7 @@ export const useRegisterEntryCommands = () => {
// width: 252,
// })
// }
collect.mutate(entry.entries.id)
collect.mutate({ entryId, view })
},
}),
defineFollowCommand({
@@ -1,5 +1,7 @@
// Entry commands
import type { FeedViewType } from "@follow/constants"
import type { Command } from "../types"
import type { COMMAND_ID } from "./id"
@@ -10,7 +12,7 @@ export type TipCommand = Command<{
export type StarCommand = Command<{
id: typeof COMMAND_ID.entry.star
fn: (data: { entryId: string }) => void
fn: (data: { entryId: string; view?: FeedViewType }) => void
}>
export type UnStarCommand = Command<{
id: typeof COMMAND_ID.entry.unstar