Skip to content

Commit

Permalink
fix: some missing seller name and image in the explore page (#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertfolch-redeemeum authored Feb 9, 2024
1 parent 3c22066 commit 861da9a
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 42 deletions.
6 changes: 4 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"@typescript-eslint",
"react-hooks",
"simple-import-sort",
"unused-imports"
"unused-imports",
"@tanstack/query"
],
"rules": {
"simple-import-sort/exports": "error",
Expand All @@ -29,7 +30,8 @@
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
"plugin:prettier/recommended",
"plugin:@tanstack/eslint-plugin-query/recommended"
],
"env": {
"browser": true,
Expand Down
209 changes: 209 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"@graphql-codegen/typescript": "^2.7.3",
"@graphql-codegen/typescript-operations": "^2.5.3",
"@playwright/test": "^1.23.1",
"@tanstack/eslint-plugin-query": "^5.18.1",
"@testing-library/react": "^13.3.0",
"@types/lodash.merge": "^4.6.7",
"@types/lodash.uniqby": "^4.7.7",
Expand Down
3 changes: 0 additions & 3 deletions src/components/core-sdk/CoreSDKProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ interface Props {
export function CoreSDKProvider({ children }: Props) {
const coreSDK = useProviderCoreSDK() as ExtendedCoreSDK;

if (!coreSDK.uuid) {
coreSDK.uuid = crypto.randomUUID();
}
return (
<CoreSDKContext.Provider value={coreSDK}>
{children}
Expand Down
55 changes: 29 additions & 26 deletions src/lib/utils/hooks/lens/profile/useGetLensProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,43 +51,46 @@ export function useLensProfilesPerSellerIds(
const { config } = useConfigContext();
const lensApiLink = config.lens.apiLink || "";
const { enabled } = options;
const sellerIdPerLensToken = props.sellers
.filter((seller) => seller.authTokenType === AuthTokenType.LENS)
.reduce((_sellerIdPerLensToken, seller) => {
const sellerId = seller.id;
const tokenId = getLensTokenIdHex(seller.authTokenId);
if (!_sellerIdPerLensToken.has(tokenId)) {
_sellerIdPerLensToken.set(tokenId, sellerId);
}
return _sellerIdPerLensToken;
}, new Map<string, string>());
const sellerIdPerLensToken = useMemo(
() =>
props.sellers
.filter((seller) => seller.authTokenType === AuthTokenType.LENS)
.reduce((_sellerIdPerLensToken, seller) => {
const sellerId = seller.id;
const tokenId = getLensTokenIdHex(seller.authTokenId);
if (!_sellerIdPerLensToken.has(tokenId)) {
_sellerIdPerLensToken.set(tokenId, sellerId);
}
return _sellerIdPerLensToken;
}, new Map<string, string>()),
[props.sellers]
);
const profileIds = Array.from(sellerIdPerLensToken.keys());
const lensProfiles = useQuery(
["get-lens-profiles", sellerIdPerLensToken, lensApiLink],
["get-lens-profiles", profileIds, lensApiLink],
async () => {
return getLensProfiles(
const lensProfiles = await getLensProfiles(
{
profileIds: Array.from(sellerIdPerLensToken.keys())
profileIds
},
lensApiLink
);
return lensProfiles?.items.reduce((map, profile) => {
if (profile) {
const sellerId = sellerIdPerLensToken.get(String(profile.id));
if (!sellerId) {
return map;
}
return map.set(sellerId, profile as Profile);
}
return map;
}, new Map<string, Profile>());
},
{
enabled: enabled && !!sellerIdPerLensToken.size
}
);
return useMemo(() => {
return lensProfiles.isSuccess && lensProfiles.data?.items
? lensProfiles.data?.items.reduce((map, profile) => {
if (profile) {
const sellerId = sellerIdPerLensToken.get(
String(profile.id)
) as string;
return map.set(sellerId, profile as Profile);
}
return map;
}, new Map<string, Profile>())
: new Map<string, Profile>();
}, [lensProfiles, sellerIdPerLensToken]);
return lensProfiles.data;
}

async function getLensProfiles(
Expand Down
Loading

0 comments on commit 861da9a

Please sign in to comment.