diff --git a/apps/desktop/layer/renderer/src/modules/discover/DiscoverFeedForm.tsx b/apps/desktop/layer/renderer/src/modules/discover/DiscoverFeedForm.tsx
index 997a40982..4f14c3e5d 100644
--- a/apps/desktop/layer/renderer/src/modules/discover/DiscoverFeedForm.tsx
+++ b/apps/desktop/layer/renderer/src/modules/discover/DiscoverFeedForm.tsx
@@ -11,7 +11,6 @@ import {
SelectTrigger,
SelectValue,
} from "@follow/components/ui/select/index.jsx"
-import { FeedViewType } from "@follow/constants"
import { nextFrame } from "@follow/utils/dom"
import {
MissingOptionalParamError,
@@ -38,7 +37,6 @@ import {
useIsTopModal,
useModalStack,
} from "~/components/ui/modal/stacked/hooks"
-import { getViewFromRoute } from "~/lib/utils"
import { FeedForm } from "./feed-form"
import type { RSSHubRoute } from "./types"
@@ -190,20 +188,10 @@ export const DiscoverFeedForm = ({
const finalUrl = routeParams && routeParamsPath ? `${url}/${routeParamsPath}` : url
- const defaultView = getViewFromRoute(route) || FeedViewType.Articles
-
present({
title: t("feed_form.add_feed"),
modalContentClassName: "overflow-visible",
- content: () => (
-
- ),
+ content: () => ,
})
} catch (err: unknown) {
if (err instanceof MissingOptionalParamError) {
diff --git a/apps/desktop/layer/renderer/src/modules/discover/feed-card.tsx b/apps/desktop/layer/renderer/src/modules/discover/feed-card.tsx
index bf7c433b5..2b062dd50 100644
--- a/apps/desktop/layer/renderer/src/modules/discover/feed-card.tsx
+++ b/apps/desktop/layer/renderer/src/modules/discover/feed-card.tsx
@@ -12,7 +12,6 @@ import { setPreviewBackPath } from "~/atoms/preview"
import { Media } from "~/components/ui/media"
import { useFollow } from "~/hooks/biz/useFollow"
import { navigateEntry } from "~/hooks/biz/useNavigateEntry"
-import { getRouteParams } from "~/hooks/biz/useRouteParams"
import { useFeedSafeUrl } from "~/hooks/common/useFeedSafeUrl"
import type { apiClient } from "~/lib/api-fetch"
import { useSubscriptionByFeedId } from "~/store/subscription"
@@ -136,9 +135,6 @@ export const FeedCard: FC<{
isList: !!item.list?.id,
id: item.list?.id || item.feed?.id,
url: item.feed?.url,
- defaultValues: {
- view: getRouteParams().view.toString(),
- },
onSuccess() {
onSuccess?.(item)
},
diff --git a/apps/desktop/layer/renderer/src/modules/discover/feed-form.tsx b/apps/desktop/layer/renderer/src/modules/discover/feed-form.tsx
index 58b3d66f4..9852717f2 100644
--- a/apps/desktop/layer/renderer/src/modules/discover/feed-form.tsx
+++ b/apps/desktop/layer/renderer/src/modules/discover/feed-form.tsx
@@ -27,6 +27,7 @@ import { z } from "zod"
import { Autocomplete } from "~/components/ui/auto-completion"
import { useCurrentModal, useIsInModal } from "~/components/ui/modal/stacked/hooks"
+import { getRouteParams } from "~/hooks/biz/useRouteParams"
import { useAuthQuery, useI18n } from "~/hooks/common"
import { apiClient } from "~/lib/api-fetch"
import { tipcClient } from "~/lib/client"
@@ -48,15 +49,13 @@ const formSchema = z.object({
})
export type FeedFormDataValuesType = z.infer
-const defaultValue = { view: FeedViewType.Articles.toString() } as FeedFormDataValuesType
-
export const FeedForm: Component<{
url?: string
id?: string
defaultValues?: FeedFormDataValuesType
onSuccess?: () => void
-}> = ({ id: _id, defaultValues = defaultValue, url, onSuccess }) => {
+}> = ({ id: _id, defaultValues, url, onSuccess }) => {
const queryParams = { id: _id, url }
const feedQuery = useFeedQuery(queryParams)
@@ -189,7 +188,9 @@ const FeedInnerForm = ({
const form = useForm>({
resolver: zodResolver(formSchema),
- defaultValues,
+ defaultValues: defaultValues || {
+ view: getRouteParams().view.toString() || FeedViewType.Articles.toString(),
+ },
})
const { setClickOutSideToDismiss, dismiss } = useCurrentModal()
@@ -207,6 +208,12 @@ const FeedInnerForm = ({
}
}, [subscription])
+ useEffect(() => {
+ if (analytics?.view !== undefined && !subscription && defaultValues?.view === undefined) {
+ form.setValue("view", `${analytics.view}`)
+ }
+ }, [analytics, subscription, defaultValues?.view])
+
const followMutation = useMutation({
mutationFn: async (values: z.infer) => {
const body = {
diff --git a/apps/desktop/layer/renderer/src/modules/discover/form.tsx b/apps/desktop/layer/renderer/src/modules/discover/form.tsx
index 0b704fde2..beb86adba 100644
--- a/apps/desktop/layer/renderer/src/modules/discover/form.tsx
+++ b/apps/desktop/layer/renderer/src/modules/discover/form.tsx
@@ -24,7 +24,6 @@ import { z } from "zod"
import { useIsInMASReview } from "~/atoms/server-configs"
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
-import { getRouteParams } from "~/hooks/biz/useRouteParams"
import { apiClient } from "~/lib/api-fetch"
import { FeedCard } from "./feed-card"
@@ -126,18 +125,9 @@ export function DiscoverForm({ type = "search" }: { type?: string }) {
function onSubmit(values: z.infer) {
if (info[type]!.showModal) {
- const defaultView = getRouteParams().view
present({
title: t("feed_form.add_feed"),
- content: () => (
-
- ),
+ content: () => ,
})
} else {
mutation.mutate(values)
diff --git a/apps/desktop/layer/renderer/src/modules/panel/cmdn.tsx b/apps/desktop/layer/renderer/src/modules/panel/cmdn.tsx
index 7f7bb5ab7..33579d6db 100644
--- a/apps/desktop/layer/renderer/src/modules/panel/cmdn.tsx
+++ b/apps/desktop/layer/renderer/src/modules/panel/cmdn.tsx
@@ -54,15 +54,7 @@ const CmdNPanel = () => {
present({
title: t("feed_form.add_feed"),
modalContentClassName: "overflow-visible",
- content: () => (
-
- ),
+ content: () => ,
})
}