Skip to content

Commit

Permalink
fix: Fix rendering of proposals for DAOs with ENS on unsupported ENS …
Browse files Browse the repository at this point in the history
…chains (#1363)
  • Loading branch information
cgero-eth authored Jun 5, 2024
1 parent 951248e commit d33caca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "GPL-3.0",
"type": "module",
"scripts": {
"dev": "vite --host",
"dev": "vite --host --force",
"dev:watch": "cross-env WATCH=true vite --host",
"build": "cross-env NODE_ENV=production vite build",
"build:analyze": "cross-env ANALYZE=true vite build",
Expand Down
35 changes: 20 additions & 15 deletions src/hooks/useDaoDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const useDaoQuery = (
: {refetchOnWindowFocus: false}),
},
refetchInterval,
select: addAvatarToDao(),
select: processDaoResponse(network),
});
};

Expand Down Expand Up @@ -239,19 +239,24 @@ export const useDaoDetailsQuery = () => {
return apiResponse;
};

/**
* Adds avatar to DAO
* @param dao DAO details
* @returns DAO details object augmented with a resolved IPFS avatar
*/
const addAvatarToDao = () => (dao: DaoDetails | null) => {
if (!dao) return null;
const processDaoResponse =
(network: SupportedNetworks) => (dao: DaoDetails | null) => {
if (!dao) {
return null;
}

return {
...dao,
metadata: {
...dao?.metadata,
avatar: dao?.metadata.avatar,
},
// Set ENS to empty string for DAOs with an ENS on chains that do not support ENS
// (e.g. when a DAO is created with an ENS outside of Aragon App)
const processedEns = !CHAIN_METADATA[network].supportsEns
? ''
: dao.ensDomain;

return {
...dao,
ensDomain: processedEns,
metadata: {
...dao?.metadata,
avatar: dao?.metadata.avatar,
},
};
};
};
5 changes: 1 addition & 4 deletions src/pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ export const Dashboard: React.FC = () => {
isSuccess,
isFetched: liveDaoFetched,
} = useDaoQuery(urlAddressOrEns, pollInterval);
const liveAddressOrEns =
network !== 'sepolia'
? toDisplayEns(liveDao?.ensDomain) || liveDao?.address
: liveDao?.address;
const liveAddressOrEns = toDisplayEns(liveDao?.ensDomain) || liveDao?.address;

// pending DAO
const {
Expand Down

0 comments on commit d33caca

Please sign in to comment.