diff --git a/src/main/index.ts b/src/main/index.ts index 67a56741d1..26dbc43f06 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -64,6 +64,12 @@ app.whenReady().then(() => { }) mainWindow.reload() } + } else { + createWindow({ + extraPath: url.replace("follow:/", ""), + width: 800, + height: 600, + }) } } @@ -137,7 +143,7 @@ Menu.setApplicationMenu( label: "follow https://rsshub.app/twitter/user/DIYgod", click: () => { createWindow({ - extraPath: `/follow?url=${encodeURIComponent("https://rsshub.app/twitter/user/DIYgod")}`, + extraPath: `/add?url=${encodeURIComponent("https://rsshub.app/twitter/user/DIYgod")}`, width: 800, height: 600, }) @@ -147,7 +153,7 @@ Menu.setApplicationMenu( label: "follow https://diygod.me/feed", click: () => { createWindow({ - extraPath: `/follow?url=${encodeURIComponent("https://diygod.me/feed")}`, + extraPath: `/add?url=${encodeURIComponent("https://diygod.me/feed")}`, width: 800, height: 600, }) diff --git a/src/renderer/src/components/discover/button.tsx b/src/renderer/src/components/discover/button.tsx deleted file mode 100644 index 1380d1daa4..0000000000 --- a/src/renderer/src/components/discover/button.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { Button } from "@renderer/components/ui/button" -import { Dialog, DialogTrigger } from "@renderer/components/ui/dialog" -import type { FeedResponse } from "@renderer/lib/types" -import { useState } from "react" - -import { FollowDialog } from "./dialog" - -export function DiscoverButton({ feed }: { feed: FeedResponse }) { - const [open, setOpen] = useState(false) - const [isSuccessful, setIsSuccessful] = useState(false) - - return ( - - - {isSuccessful ? - ( - - ) : - ( - - )} - - { - setOpen(false) - setIsSuccessful(true) - }} - isSubscribed={false} - /> - - ) -} diff --git a/src/renderer/src/components/discover/dialog.tsx b/src/renderer/src/components/discover/dialog.tsx deleted file mode 100644 index 375bee25ac..0000000000 --- a/src/renderer/src/components/discover/dialog.tsx +++ /dev/null @@ -1,192 +0,0 @@ -import { zodResolver } from "@hookform/resolvers/zod" -import { AutoComplete } from "@renderer/components/ui/autocomplete" -import { Button } from "@renderer/components/ui/button" -import { - DialogContent, - DialogHeader, - DialogTitle, -} from "@renderer/components/ui/dialog" -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@renderer/components/ui/form" -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@renderer/components/ui/select" -import { Switch } from "@renderer/components/ui/switch" -import { useBizQuery } from "@renderer/hooks/useBizQuery" -import { views } from "@renderer/lib/constants" -import type { SubscriptionResponse } from "@renderer/lib/types" -import { cn } from "@renderer/lib/utils" -import { Queries } from "@renderer/queries" -import { apiFetch } from "@renderer/queries/api-fetch" -import { useMutation } from "@tanstack/react-query" -import { useForm } from "react-hook-form" -import { z } from "zod" - -import { FollowSummary } from "../feed-summary" - -const formSchema = z.object({ - view: z.string(), - category: z.string().nullable().optional(), - isPrivate: z.boolean().optional(), -}) - -export function FollowDialog({ - feed, - onSuccess, - isSubscribed, -}: - | { - feed: - | SubscriptionResponse[number] - | { - feeds: SubscriptionResponse[number]["feeds"] - } - onSuccess?: (values: z.infer) => void - isSubscribed?: false - } - | { - feed: SubscriptionResponse[number] - onSuccess?: (values: z.infer) => void - isSubscribed: true - }) { - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - view: isSubscribed ? `${feed.view}` : "0", - category: isSubscribed ? feed.category : undefined, - isPrivate: isSubscribed ? feed.isPrivate || false : false, - }, - }) - - const followMutation = useMutation({ - mutationFn: async (values: z.infer) => - apiFetch("/subscriptions", { - method: isSubscribed ? "PATCH" : "POST", - body: { - url: feed.feeds.url, - view: Number.parseInt(values.view), - category: values.category, - isPrivate: values.isPrivate, - ...(isSubscribed && { feedId: feed.feeds.id }), - }, - }), - onSuccess: (_, variables) => { - if (isSubscribed && variables.view !== `${feed.view}`) { - Queries.subscription.byView(feed.view).invalidate() - } - Queries.subscription.byView(Number.parseInt(variables.view)).invalidate() - - onSuccess?.(variables) - }, - }) - - function onSubmit(values: z.infer) { - followMutation.mutate(values) - } - - const categories = useBizQuery( - Queries.subscription.categories(Number.parseInt(form.watch("view"))), - ) - - return ( - - - Follow - - -
- - ( - - View - - - - )} - /> - ( - -
- Category - - By default, your follows will be grouped by website. - -
- - - - -
- )} - /> - ( - -
- Prviate Follow - - Whether this follow is publicly visible on your profile - page. - -
- - - -
- )} - /> - - - -
- ) -} diff --git a/src/renderer/src/components/discover/form.tsx b/src/renderer/src/components/discover/form.tsx index d5a86ee421..9330809d13 100644 --- a/src/renderer/src/components/discover/form.tsx +++ b/src/renderer/src/components/discover/form.tsx @@ -24,7 +24,6 @@ import { useForm } from "react-hook-form" import { z } from "zod" import { FollowSummary } from "../feed-summary" -import { DiscoverButton } from "./button" const formSchema = z.object({ keyword: z.string().min(1), @@ -186,7 +185,7 @@ export function DiscoverForm({ type }: { type: string }) { ) : ( - + )}
diff --git a/src/renderer/src/components/feed-column/item.tsx b/src/renderer/src/components/feed-column/item.tsx index 6fcfb0a581..ba985a4676 100644 --- a/src/renderer/src/components/feed-column/item.tsx +++ b/src/renderer/src/components/feed-column/item.tsx @@ -1,6 +1,4 @@ -import { FollowDialog } from "@renderer/components/discover/dialog" import { FeedIcon } from "@renderer/components/feed-icon" -import { Dialog } from "@renderer/components/ui/dialog" import { ToastAction } from "@renderer/components/ui/toast" import { Tooltip, @@ -19,7 +17,6 @@ import { Queries } from "@renderer/queries" import { apiFetch } from "@renderer/queries/api-fetch" import { feedActions, useFeedActiveList } from "@renderer/store" import { useMutation } from "@tanstack/react-query" -import { useState } from "react" export function FeedItem({ feed, @@ -30,7 +27,6 @@ export function FeedItem({ view?: number className?: string }) { - const [dialogOpen, setDialogOpen] = useState(false) const activeList = useFeedActiveList() const { setActiveList } = feedActions @@ -93,115 +89,108 @@ export function FeedItem({ }) return ( - +
{ + e.stopPropagation() + setFeedActive(feed) + }} + onDoubleClick={() => { + window.open( + `${import.meta.env.VITE_WEB_URL}/feed/${feed.feedId}`, + "_blank", + ) + }} + onContextMenu={(e) => { + showNativeMenu( + [ + { + type: "text", + label: "Edit", + click: () => window.open(`follow://add?id=${feed.feedId}`), + }, + { + type: "text", + label: "Unfollow", + click: () => deleteMutation.mutate(feed), + }, + { + type: "separator", + }, + { + type: "text", + label: "Open Feed in Browser", + click: () => + window.open( + `${import.meta.env.VITE_WEB_URL}/feed/${feed.feedId}?view=${view}`, + "_blank", + ), + }, + { + type: "text", + label: "Open Site in Browser", + click: () => + feed.feeds.siteUrl && + window.open(feed.feeds.siteUrl, "_blank"), + }, + ], + e, + ) + }} + >
{ - e.stopPropagation() - setFeedActive(feed) - }} - onDoubleClick={() => { - window.open( - `${import.meta.env.VITE_WEB_URL}/feed/${feed.feedId}`, - "_blank", - ) - }} - onContextMenu={(e) => { - showNativeMenu( - [ - { - type: "text", - label: "Edit", - click: () => setDialogOpen(true), - }, - { - type: "text", - label: "Unfollow", - click: () => deleteMutation.mutate(feed), - }, - { - type: "separator", - }, - { - type: "text", - label: "Open Feed in Browser", - click: () => - window.open( - `${import.meta.env.VITE_WEB_URL}/feed/${feed.feedId}?view=${view}`, - "_blank", - ), - }, - { - type: "text", - label: "Open Site in Browser", - click: () => - feed.feeds.siteUrl && - window.open(feed.feeds.siteUrl, "_blank"), - }, - ], - e, - ) - }} > -
- -
{feed.feeds.title}
- {feed.feeds.errorAt && ( - - - - - - - - Error since - {" "} - {dayjs - .duration( - dayjs(feed.feeds.errorAt).diff(dayjs(), "minute"), - "minute", - ) - .humanize(true)} - - - - - )} - {feed.isPrivate && ( - - - - - - - - Not publicly visible on your profile page - - - - - )} -
- {!!feed.unread && ( -
{feed.unread}
+ +
{feed.feeds.title}
+ {feed.feeds.errorAt && ( + + + + + + + + Error since + {" "} + {dayjs + .duration( + dayjs(feed.feeds.errorAt).diff(dayjs(), "minute"), + "minute", + ) + .humanize(true)} + + + + + )} + {feed.isPrivate && ( + + + + + + + + Not publicly visible on your profile page + + + + )} - setDialogOpen(false)} - isSubscribed={true} - />
-
+ {!!feed.unread && ( +
{feed.unread}
+ )} +
) } diff --git a/src/renderer/src/pages/add/index.tsx b/src/renderer/src/pages/add/index.tsx index 4960fcaa45..975ef2a8ad 100644 --- a/src/renderer/src/pages/add/index.tsx +++ b/src/renderer/src/pages/add/index.tsx @@ -99,7 +99,7 @@ export function Component() {
logo - New follow + Add follow
{feed.isLoading ? (