From 2d33a2213336f1eba6fa0a59c412d7f1df29adba Mon Sep 17 00:00:00 2001
From: Stephen Zhou <38493346+hyoban@users.noreply.github.com>
Date: Thu, 17 Apr 2025 20:18:49 +0800
Subject: [PATCH] feat(rsshub): delete instance, close #2883
---
.../modules/rsshub/delete-modal-content.tsx | 43 +++++++++++++++++++
.../(main)/(layer)/(subview)/rsshub/index.tsx | 21 +++++++++
locales/settings/en.json | 3 ++
3 files changed, 67 insertions(+)
create mode 100644 apps/desktop/src/renderer/src/modules/rsshub/delete-modal-content.tsx
diff --git a/apps/desktop/src/renderer/src/modules/rsshub/delete-modal-content.tsx b/apps/desktop/src/renderer/src/modules/rsshub/delete-modal-content.tsx
new file mode 100644
index 000000000..230d115b6
--- /dev/null
+++ b/apps/desktop/src/renderer/src/modules/rsshub/delete-modal-content.tsx
@@ -0,0 +1,43 @@
+import { Button } from "@follow/components/ui/button/index.js"
+import { useMutation } from "@tanstack/react-query"
+import { useTranslation } from "react-i18next"
+import { toast } from "sonner"
+
+import { apiClient } from "~/lib/api-fetch"
+import { Queries } from "~/queries"
+
+export const ConfirmDeleteModalContent = ({ id, dismiss }: { dismiss: () => void; id: string }) => {
+ const { t } = useTranslation("settings")
+ const deleteMutation = useMutation({
+ mutationFn: () => {
+ return apiClient.rsshub.$delete({ json: { id } })
+ },
+ onSuccess: () => {
+ Queries.rsshub.list().invalidate()
+ toast.success(t("rsshub.table.delete.success"))
+ },
+ onError: (error) => {
+ toast.error(error.message)
+ },
+ })
+
+ return (
+
+
+
+ {t("rsshub.table.delete.confirm")}
+
+
+
+
+
+ )
+}
diff --git a/apps/desktop/src/renderer/src/pages/(main)/(layer)/(subview)/rsshub/index.tsx b/apps/desktop/src/renderer/src/pages/(main)/(layer)/(subview)/rsshub/index.tsx
index a42842c22..40f036eca 100644
--- a/apps/desktop/src/renderer/src/pages/(main)/(layer)/(subview)/rsshub/index.tsx
+++ b/apps/desktop/src/renderer/src/pages/(main)/(layer)/(subview)/rsshub/index.tsx
@@ -19,6 +19,7 @@ import { useAuthQuery } from "~/hooks/common"
import { useSubViewTitle } from "~/modules/app-layout/subview/hooks"
import { useTOTPModalWrapper } from "~/modules/profile/hooks"
import { AddModalContent } from "~/modules/rsshub/add-modal-content"
+import { ConfirmDeleteModalContent } from "~/modules/rsshub/delete-modal-content"
import { SetModalContent } from "~/modules/rsshub/set-modal-content"
import { UserAvatar } from "~/modules/user/UserAvatar"
import { Queries } from "~/queries"
@@ -145,6 +146,10 @@ function List({ data }: { data?: RSSHubModel[] }) {
return a.price - b.price || loadA - loadB
})
.map((instance) => {
+ const instanceUserCountExceptOwner = instance.userCount
+ ? instance.userCount - (instance.ownerUserId === me?.id ? 1 : 0)
+ : 0
+
return (
@@ -226,6 +231,22 @@ function List({ data }: { data?: RSSHubModel[] }) {
{t("rsshub.table.edit")}
)}
+ {me?.id === instance.ownerUserId && (
+
+ )}
diff --git a/locales/settings/en.json b/locales/settings/en.json
index 49d79caa6..03fc211a5 100644
--- a/locales/settings/en.json
+++ b/locales/settings/en.json
@@ -379,6 +379,9 @@
"rsshub.add_new_instance": "Add New Instance",
"rsshub.description": "RSSHub is a community-driven open-source RSS network. Folo provides a built-in dedicated instance and uses it to support thousands of subscription contents, you can also achieve more stable content acquisition by using your own or third-party instances.",
"rsshub.public_instances": "Available Instances",
+ "rsshub.table.delete.confirm": "Are you sure you want to delete this instance?",
+ "rsshub.table.delete.label": "Delete",
+ "rsshub.table.delete.success": "Instance deleted successfully.",
"rsshub.table.description": "Description",
"rsshub.table.edit": "Edit",
"rsshub.table.inuse": "In Use",