fix: show toast when follow fail

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei 2024-07-30 17:46:10 +08:00
parent b9c050ba1a
commit c38bb94d10
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
3 changed files with 19 additions and 6 deletions

View File

@ -2949,8 +2949,8 @@ declare const _routes: hono_hono_base.HonoBase<hono_types.BlankEnv, {
output: {
data: {
json: string;
description: string;
xml: string;
description: string;
content: string;
};
code: 0;
@ -3106,13 +3106,13 @@ declare const _routes: hono_hono_base.HonoBase<hono_types.BlankEnv, {
url: string;
routes: {
[x: string]: {
description: string;
path: string;
example: string;
description: string;
name: string;
parameters: {
[x: string]: string;
};
name: string;
categories: string[];
maintainers: string[];
location: string;

View File

@ -19,7 +19,7 @@ import { Switch } from "@renderer/components/ui/switch"
import { views } from "@renderer/constants"
import { useDeleteSubscription } from "@renderer/hooks/biz/useSubscriptionActions"
import { useAuthQuery } from "@renderer/hooks/common"
import { apiClient } from "@renderer/lib/api-fetch"
import { apiClient, getFetchErrorMessage } from "@renderer/lib/api-fetch"
import { tipcClient } from "@renderer/lib/client"
import { nextFrame } from "@renderer/lib/dom"
import { FeedViewType } from "@renderer/lib/enum"
@ -131,6 +131,9 @@ export const FeedForm: Component<{
onSuccess?.()
},
async onError(err) {
toast.error(getFetchErrorMessage(err))
},
})
const deleteSubscription = useDeleteSubscription({
@ -213,7 +216,13 @@ export const FeedForm: Component<{
value={view.view}
{...form.register("view")}
/>
<label htmlFor={view.name} className={cn(view.peerClassName, "center flex h-10 flex-col text-xs leading-none text-theme-vibrancyFg")}>
<label
htmlFor={view.name}
className={cn(
view.peerClassName,
"center flex h-10 flex-col text-xs leading-none text-theme-vibrancyFg",
)}
>
<span className="text-lg">{view.icon}</span>
{view.name}
</label>

View File

@ -10,13 +10,14 @@ import {
FormMessage,
} from "@renderer/components/ui/form"
import { Input } from "@renderer/components/ui/input"
import { apiFetch } from "@renderer/lib/api-fetch"
import { apiFetch, getFetchErrorMessage } from "@renderer/lib/api-fetch"
import { cn } from "@renderer/lib/utils"
import type { FeedResponse } from "@renderer/models"
import { Queries } from "@renderer/queries"
import { useMutation } from "@tanstack/react-query"
import { Fragment } from "react/jsx-runtime"
import { useForm } from "react-hook-form"
import { toast } from "sonner"
import { z } from "zod"
import { FollowSummary } from "../../components/feed-summary"
@ -78,6 +79,9 @@ export function DiscoverImport() {
onSuccess: () => {
Queries.subscription.byView().invalidateRoot()
},
async onError(err) {
toast.error(getFetchErrorMessage(err))
},
})
function onSubmit(values: z.infer<typeof formSchema>) {