refactor(store): use transition to support rollback
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { Trans, useTranslation } from "react-i18next"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { createErrorToaster } from "~/lib/error-parser"
|
||||
import { subscriptionActions } from "~/store/subscription"
|
||||
|
||||
import { useCurrentModal } from "../../components/ui/modal/stacked/hooks"
|
||||
@@ -10,6 +12,10 @@ export function CategoryRemoveDialogContent({ feedIdList }: { feedIdList: string
|
||||
const { t } = useTranslation()
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: () => subscriptionActions.deleteCategory(feedIdList),
|
||||
onError: createErrorToaster(t("sidebar.category_remove_dialog.error")),
|
||||
onSuccess: () => {
|
||||
toast.success(t("sidebar.category_remove_dialog.success"))
|
||||
},
|
||||
})
|
||||
|
||||
const { dismiss } = useCurrentModal()
|
||||
|
||||
@@ -11,6 +11,7 @@ import { AnimatePresence, m } from "framer-motion"
|
||||
import type { FC } from "react"
|
||||
import { Fragment, memo, useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { toast } from "sonner"
|
||||
import { useOnClickOutside } from "usehooks-ts"
|
||||
|
||||
import type { MenuItemInput } from "~/atoms/context-menu"
|
||||
@@ -18,6 +19,7 @@ import { useShowContextMenu } from "~/atoms/context-menu"
|
||||
import { ROUTE_FEED_IN_FOLDER } from "~/constants"
|
||||
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
|
||||
import { getRouteParams, useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
import { createErrorToaster } from "~/lib/error-parser"
|
||||
import { getPreferredTitle, useAddFeedToFeedList, useFeedStore } from "~/store/feed"
|
||||
import { useOwnedListByView } from "~/store/list"
|
||||
import {
|
||||
@@ -337,6 +339,7 @@ const RenameCategoryForm: FC<{
|
||||
onFinished: () => void
|
||||
}> = ({ currentCategory, onFinished }) => {
|
||||
const navigate = useNavigateEntry()
|
||||
const { t } = useTranslation()
|
||||
const renameMutation = useMutation({
|
||||
mutationFn: async ({
|
||||
lastCategory,
|
||||
@@ -356,6 +359,10 @@ const RenameCategoryForm: FC<{
|
||||
|
||||
onFinished()
|
||||
},
|
||||
onError: createErrorToaster(t("sidebar.feed_column.context_menu.rename_category_error")),
|
||||
onSuccess: () => {
|
||||
toast.success(t("sidebar.feed_column.context_menu.rename_category_success"))
|
||||
},
|
||||
})
|
||||
const formRef = useRef<HTMLFormElement>(null)
|
||||
useOnClickOutside(
|
||||
|
||||
Reference in New Issue
Block a user