Skip to content

Commit

Permalink
Fix issue where lists can't be shown on profile
Browse files Browse the repository at this point in the history
We were using handle to fetch lists, instead of user's DID.
  • Loading branch information
pdelfan committed Jan 30, 2024
1 parent 0b72038 commit cce92ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/containers/lists/ListsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ListItem from "@/components/contentDisplay/listItem/ListItem";
import ListsSkeleton from "@/components/contentDisplay/lists/ListsSkeleton";
import FeedAlert from "@/components/feedback/feedAlert/FeedAlert";
import LoadingSpinner from "@/components/status/loadingSpinner/LoadingSpinner";
import { getProfile } from "@/lib/api/bsky/actor";
import { getLists } from "@/lib/api/bsky/list";
import useAgent from "@/lib/hooks/bsky/useAgent";
import { useInfiniteQuery } from "@tanstack/react-query";
Expand All @@ -28,7 +29,11 @@ export default function ListsContainer(props: Props) {
fetchNextPage,
} = useInfiniteQuery({
queryKey: ["user lists", handle],
queryFn: ({ pageParam }) => getLists(handle, pageParam, agent),
queryFn: async ({ pageParam }) => {
const profile = await getProfile(handle, agent);
if (!profile) throw new Error("Could not get user id to show lists");
return getLists(profile.did, pageParam, agent);
},
initialPageParam: "",
getNextPageParam: (lastPage) => lastPage?.cursor,
});
Expand Down
3 changes: 2 additions & 1 deletion src/lib/api/bsky/list/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type BskyAgent, AppBskyActorDefs } from "@atproto/api";
import { type BskyAgent } from "@atproto/api";

export const getLists = async (
did: string,
Expand All @@ -9,6 +9,7 @@ export const getLists = async (
actor: did,
cursor: cursor,
});

if (!lists.success) throw new Error("Could not fetch list");
return lists.data;
};
Expand Down

0 comments on commit cce92ef

Please sign in to comment.