feat: show discovery result in modal
This commit is contained in:
+16
-10
@@ -2965,7 +2965,6 @@ declare const _routes: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
||||
input: {
|
||||
json: {
|
||||
keyword: string;
|
||||
type?: "auto" | "rss" | undefined;
|
||||
};
|
||||
};
|
||||
output: {
|
||||
@@ -3101,7 +3100,14 @@ declare const _routes: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
||||
status: hono_utils_http_status.StatusCode;
|
||||
};
|
||||
};
|
||||
} & {
|
||||
[x: `/entries/check-new/${string}`]: {
|
||||
[x: `$${Lowercase<string>}`]: {
|
||||
input: Partial<hono.ValidationTargets>;
|
||||
output: any;
|
||||
outputFormat: string;
|
||||
status: hono_utils_http_status.StatusCode;
|
||||
};
|
||||
};
|
||||
"/entries": {
|
||||
$post: {
|
||||
input: {
|
||||
@@ -3110,8 +3116,8 @@ declare const _routes: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
||||
feedId?: string | undefined;
|
||||
feedIdList?: string[] | undefined;
|
||||
read?: boolean | undefined;
|
||||
limit?: number | undefined;
|
||||
publishedAfter?: string | undefined;
|
||||
limit?: number | undefined;
|
||||
collected?: boolean | undefined;
|
||||
};
|
||||
};
|
||||
@@ -3217,13 +3223,6 @@ declare const _routes: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
||||
ownerUserId: string | null;
|
||||
};
|
||||
read: boolean | null;
|
||||
collections: {
|
||||
createdAt: string;
|
||||
};
|
||||
entryReadHistories: {
|
||||
userIds: string[];
|
||||
readCount: number;
|
||||
} | null;
|
||||
users: {
|
||||
[x: string]: {
|
||||
name: string | null;
|
||||
@@ -3232,6 +3231,13 @@ declare const _routes: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
||||
handle: string | null;
|
||||
};
|
||||
};
|
||||
entryReadHistories: {
|
||||
userIds: string[];
|
||||
readCount: number;
|
||||
} | null;
|
||||
collections: {
|
||||
createdAt: string;
|
||||
};
|
||||
settings?: {
|
||||
summary?: boolean | undefined;
|
||||
translation?: "en" | "ja" | "zh-CN" | "zh-TW" | undefined;
|
||||
|
||||
@@ -19,6 +19,7 @@ import { Image } from "@renderer/components/ui/image"
|
||||
import { Input } from "@renderer/components/ui/input"
|
||||
import { useModalStack } from "@renderer/components/ui/modal/stacked/hooks"
|
||||
import { apiClient } from "@renderer/lib/api-fetch"
|
||||
import type { FeedViewType } from "@renderer/lib/enum"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { useEffect } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
@@ -36,6 +37,7 @@ const info: Record<
|
||||
{
|
||||
label: string
|
||||
prefix?: string
|
||||
showModal?: boolean
|
||||
}
|
||||
> = {
|
||||
search: {
|
||||
@@ -43,10 +45,13 @@ const info: Record<
|
||||
},
|
||||
rss: {
|
||||
label: "RSS URL",
|
||||
prefix: "https://",
|
||||
showModal: true,
|
||||
},
|
||||
rsshub: {
|
||||
label: "RSSHub Route",
|
||||
prefix: "rsshub://",
|
||||
showModal: true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -63,7 +68,6 @@ export function DiscoverForm({ type }: { type: string }) {
|
||||
const { data } = await apiClient.discover.$post({
|
||||
json: {
|
||||
keyword,
|
||||
type: type === "rss" ? "rss" : "auto",
|
||||
},
|
||||
})
|
||||
|
||||
@@ -71,8 +75,25 @@ export function DiscoverForm({ type }: { type: string }) {
|
||||
},
|
||||
})
|
||||
|
||||
const { present, dismissAll } = useModalStack()
|
||||
|
||||
function onSubmit(values: z.infer<typeof formSchema>) {
|
||||
mutation.mutate(values.keyword)
|
||||
if (info[type].showModal) {
|
||||
const defaultView = getSidebarActiveView() as FeedViewType
|
||||
present({
|
||||
title: "Add follow",
|
||||
content: () => (
|
||||
<FeedForm
|
||||
asWidget
|
||||
url={values.keyword}
|
||||
defaultView={defaultView}
|
||||
onSuccess={dismissAll}
|
||||
/>
|
||||
),
|
||||
})
|
||||
} else {
|
||||
mutation.mutate(values.keyword)
|
||||
}
|
||||
}
|
||||
|
||||
const keyword = form.watch("keyword")
|
||||
@@ -86,8 +107,6 @@ export function DiscoverForm({ type }: { type: string }) {
|
||||
}
|
||||
}, [keyword])
|
||||
|
||||
const { present } = useModalStack()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form {...form}>
|
||||
@@ -110,7 +129,7 @@ export function DiscoverForm({ type }: { type: string }) {
|
||||
/>
|
||||
<div className="center flex">
|
||||
<StyledButton type="submit" isLoading={mutation.isPending}>
|
||||
Search
|
||||
{info[type].showModal ? "Preview" : "Search"}
|
||||
</StyledButton>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -110,9 +110,11 @@ export function DiscoverImport() {
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<StyledButton type="submit" isLoading={mutation.isPending}>
|
||||
Import
|
||||
</StyledButton>
|
||||
<div className="center flex">
|
||||
<StyledButton type="submit" isLoading={mutation.isPending}>
|
||||
Import
|
||||
</StyledButton>
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
{mutation.isSuccess && (
|
||||
|
||||
Reference in New Issue
Block a user