Skip to content

Commit

Permalink
Merge pull request #2078 from decentdao/hotfix/infinity-loops-on-larg…
Browse files Browse the repository at this point in the history
…e-hierarchy

Hot-fix navigating to subDAO from hierarchy page when parent DAO has large amount of subDAOs
  • Loading branch information
adamgall committed Jul 5, 2024
2 parents cfe7d70 + 846b404 commit 56a139a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"js-big-decimal": "^1.3.12",
"lodash.camelcase": "^4.3.0",
"lodash.debounce": "^4.0.8",
"lodash.isequal": "^4.5.0",
"moralis": "^2.26.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down Expand Up @@ -94,6 +95,7 @@
"@testing-library/react": "^14.2.1",
"@types/lodash.camelcase": "^4.3.9",
"@types/lodash.debounce": "^4.0.9",
"@types/lodash.isequal": "^4.5.8",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@typescript-eslint/eslint-plugin": "^6.19.0",
Expand Down
5 changes: 4 additions & 1 deletion src/hooks/utils/useCanUserSubmitProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ export function useCanUserCreateProposal() {
);
useEffect(() => {
const loadCanUserCreateProposal = async () => {
setCanUserCreateProposal(await getCanUserCreateProposal());
const newCanCreateProposal = await getCanUserCreateProposal();
if (newCanCreateProposal !== canUserCreateProposal) {
setCanUserCreateProposal(newCanCreateProposal);
}
};
loadCanUserCreateProposal();
}, [getCanUserCreateProposal, canUserCreateProposal]);
Expand Down
10 changes: 7 additions & 3 deletions src/providers/App/useReadOnlyValues.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ERC721__factory } from '@fractal-framework/fractal-contracts';
import * as Sentry from '@sentry/react';
import isEqual from 'lodash.isequal';
import { useEffect, useState, useCallback } from 'react';
import { getAddress } from 'viem';
import useSignerOrProvider from '../../hooks/utils/useSignerOrProvider';
Expand Down Expand Up @@ -61,7 +62,7 @@ export const useReadOnlyValues = ({ node, governance }: Fractal, _account?: stri
const address = _account ? getAddress(_account) : undefined;
Sentry.setUser(address ? { id: address } : null);

setReadOnlyValues({
const newReadOnlyValues = {
user: {
address,
votingWeight: await getVotingWeight(),
Expand All @@ -73,8 +74,11 @@ export const useReadOnlyValues = ({ node, governance }: Fractal, _account?: stri
governance.type === GovernanceType.AZORIUS_ERC20 ||
governance.type === GovernanceType.AZORIUS_ERC721,
},
});
}, [node, governance, _account, signerOrProvider]);
};
if (!isEqual(newReadOnlyValues, readOnlyValues)) {
setReadOnlyValues(newReadOnlyValues);
}
}, [node, governance, _account, signerOrProvider, readOnlyValues]);
useEffect(() => {
loadReadOnlyValues();
}, [loadReadOnlyValues]);
Expand Down

0 comments on commit 56a139a

Please sign in to comment.