Skip to content

Commit c7607de

Browse files
committed
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 <[email protected]>
1 parent d39f95c commit c7607de

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

apps/desktop/layer/renderer/src/modules/settings/tabs/lists/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const ConfirmDestroyModalContent = ({ listId }: { listId: string }) => {
4040
mutationFn: (payload: { listId: string }) => listActions.deleteList(payload.listId),
4141
onSuccess: () => {
4242
toast.success(t.settings("lists.delete.success"))
43-
Queries.lists.list().invalidate()
4443
},
4544
onError() {
4645
toast.error(t.settings("lists.delete.error"))

apps/desktop/layer/renderer/src/modules/subscription-column/SubscriptionList.electron.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ const SubscriptionImpl = ({ ref, className, view }: SubscriptionProps) => {
5858
// Data prefetch
5959
useAuthQuery(Queries.lists.list())
6060

61-
const hasListData = Object.keys(listSubIds).length > 0
62-
const hasInboxData = Object.keys(inboxSubIds).length > 0
61+
const hasListData = listSubIds.length > 0
62+
const hasInboxData = inboxSubIds.length > 0
6363

6464
const scrollerRef = useRef<HTMLDivElement | null>(null)
6565
const selectoRef = useRef<Selecto>(null)

apps/desktop/layer/renderer/src/modules/subscription-column/SubscriptionList.mobile.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,20 @@ import { EmptyFeedList, ListHeader, StarredItem } from "./SubscriptionList.share
2121

2222
const FeedListImpl = ({ className, view }: SubscriptionProps) => {
2323
const feedsData = useFeedsGroupedData(view)
24-
const listsData = useSubscriptionListIds(view)
25-
const inboxesData = useSubscriptionInboxIds(view)
24+
const listSubIds = useSubscriptionListIds(view)
25+
const inboxSubIds = useSubscriptionInboxIds(view)
2626
const categoryOpenStateData = useCategoryOpenStateByView(view)
2727

2828
const hasData =
29-
Object.keys(feedsData).length > 0 ||
30-
Object.keys(listsData).length > 0 ||
31-
Object.keys(inboxesData).length > 0
29+
Object.keys(feedsData).length > 0 || listSubIds.length > 0 || inboxSubIds.length > 0
3230

3331
const { t } = useTranslation()
3432

3533
// Data prefetch
3634
useAuthQuery(Queries.lists.list())
3735

38-
const hasListData = Object.keys(listsData).length > 0
39-
const hasInboxData = Object.keys(inboxesData).length > 0
36+
const hasListData = listSubIds.length > 0
37+
const hasInboxData = inboxSubIds.length > 0
4038

4139
const currentActiveView = useRouteParamsSelector((s) => s.view)
4240
// Render only adjacent views
@@ -58,15 +56,15 @@ const FeedListImpl = ({ className, view }: SubscriptionProps) => {
5856
<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">
5957
{t("words.lists")}
6058
</div>
61-
<SortByAlphabeticalList view={view} data={listsData} />
59+
<SortByAlphabeticalList view={view} data={listSubIds} />
6260
</>
6361
)}
6462
{hasInboxData && (
6563
<>
6664
<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">
6765
{t("words.inbox")}
6866
</div>
69-
<SortByAlphabeticalInbox view={view} data={inboxesData} />
67+
<SortByAlphabeticalInbox view={view} data={inboxSubIds} />
7068
</>
7169
)}
7270

apps/desktop/layer/renderer/src/store/list/store.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type {
55
ListModel,
66
ListModelPoplutedFeeds,
77
} from "@follow/models/types"
8-
import { sleep } from "@follow/utils/utils"
98

109
import { runTransactionInScope } from "~/database"
1110
import { apiClient } from "~/lib/api-fetch"
@@ -97,8 +96,7 @@ class ListActionStatic {
9796
})
9897
})
9998
tx.execute(async () => {
100-
await sleep(1000)
101-
99+
await subscriptionActions.unfollow([listId])
102100
await apiClient.lists.$delete({
103101
json: {
104102
listId,

0 commit comments

Comments
 (0)