fix: unfollow before list delete
- Replaced object key checks with direct array length checks for list and inbox subscriptions to enhance performance and readability. - Updated components to utilize the new subscription ID variables for improved clarity in data management. - Removed unnecessary list invalidation after deletion to simplify the mutation success flow. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -40,7 +40,6 @@ const ConfirmDestroyModalContent = ({ listId }: { listId: string }) => {
|
||||
mutationFn: (payload: { listId: string }) => listActions.deleteList(payload.listId),
|
||||
onSuccess: () => {
|
||||
toast.success(t.settings("lists.delete.success"))
|
||||
Queries.lists.list().invalidate()
|
||||
},
|
||||
onError() {
|
||||
toast.error(t.settings("lists.delete.error"))
|
||||
|
||||
+2
-2
@@ -58,8 +58,8 @@ const SubscriptionImpl = ({ ref, className, view }: SubscriptionProps) => {
|
||||
// Data prefetch
|
||||
useAuthQuery(Queries.lists.list())
|
||||
|
||||
const hasListData = Object.keys(listSubIds).length > 0
|
||||
const hasInboxData = Object.keys(inboxSubIds).length > 0
|
||||
const hasListData = listSubIds.length > 0
|
||||
const hasInboxData = inboxSubIds.length > 0
|
||||
|
||||
const scrollerRef = useRef<HTMLDivElement | null>(null)
|
||||
const selectoRef = useRef<Selecto>(null)
|
||||
|
||||
+7
-9
@@ -21,22 +21,20 @@ import { EmptyFeedList, ListHeader, StarredItem } from "./SubscriptionList.share
|
||||
|
||||
const FeedListImpl = ({ className, view }: SubscriptionProps) => {
|
||||
const feedsData = useFeedsGroupedData(view)
|
||||
const listsData = useSubscriptionListIds(view)
|
||||
const inboxesData = useSubscriptionInboxIds(view)
|
||||
const listSubIds = useSubscriptionListIds(view)
|
||||
const inboxSubIds = useSubscriptionInboxIds(view)
|
||||
const categoryOpenStateData = useCategoryOpenStateByView(view)
|
||||
|
||||
const hasData =
|
||||
Object.keys(feedsData).length > 0 ||
|
||||
Object.keys(listsData).length > 0 ||
|
||||
Object.keys(inboxesData).length > 0
|
||||
Object.keys(feedsData).length > 0 || listSubIds.length > 0 || inboxSubIds.length > 0
|
||||
|
||||
const { t } = useTranslation()
|
||||
|
||||
// Data prefetch
|
||||
useAuthQuery(Queries.lists.list())
|
||||
|
||||
const hasListData = Object.keys(listsData).length > 0
|
||||
const hasInboxData = Object.keys(inboxesData).length > 0
|
||||
const hasListData = listSubIds.length > 0
|
||||
const hasInboxData = inboxSubIds.length > 0
|
||||
|
||||
const currentActiveView = useRouteParamsSelector((s) => s.view)
|
||||
// Render only adjacent views
|
||||
@@ -58,7 +56,7 @@ const FeedListImpl = ({ className, view }: SubscriptionProps) => {
|
||||
<div className="text-text-secondary mt-1 flex h-6 w-full shrink-0 items-center rounded-md px-2.5 text-xs font-semibold transition-colors">
|
||||
{t("words.lists")}
|
||||
</div>
|
||||
<SortByAlphabeticalList view={view} data={listsData} />
|
||||
<SortByAlphabeticalList view={view} data={listSubIds} />
|
||||
</>
|
||||
)}
|
||||
{hasInboxData && (
|
||||
@@ -66,7 +64,7 @@ const FeedListImpl = ({ className, view }: SubscriptionProps) => {
|
||||
<div className="text-text-secondary mt-1 flex h-6 w-full shrink-0 items-center rounded-md px-2.5 text-xs font-semibold transition-colors">
|
||||
{t("words.inbox")}
|
||||
</div>
|
||||
<SortByAlphabeticalInbox view={view} data={inboxesData} />
|
||||
<SortByAlphabeticalInbox view={view} data={inboxSubIds} />
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import type {
|
||||
ListModel,
|
||||
ListModelPoplutedFeeds,
|
||||
} from "@follow/models/types"
|
||||
import { sleep } from "@follow/utils/utils"
|
||||
|
||||
import { runTransactionInScope } from "~/database"
|
||||
import { apiClient } from "~/lib/api-fetch"
|
||||
@@ -97,8 +96,7 @@ class ListActionStatic {
|
||||
})
|
||||
})
|
||||
tx.execute(async () => {
|
||||
await sleep(1000)
|
||||
|
||||
await subscriptionActions.unfollow([listId])
|
||||
await apiClient.lists.$delete({
|
||||
json: {
|
||||
listId,
|
||||
|
||||
Reference in New Issue
Block a user