Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PRD] | [Issue #2529] Organization Hierarchy Cache #2566

Merged
merged 45 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e8d882f
Refactor DaoHierarchyNode and DAONodeInfoCard components for improved…
Da-Colon Nov 22, 2024
7e54387
Add HierarchyDAOInfo cache key and interface for improved caching str…
Da-Colon Nov 22, 2024
7696e74
Implement caching for DAO hierarchy nodes to enhance performance and …
Da-Colon Nov 22, 2024
31bb81d
Refactor DaoHierarchyNode to use DaoHierarchyInfo type and update cac…
Da-Colon Nov 22, 2024
d882324
Merge branch 'develop' into issue/2529-cache-it
Da-Colon Nov 22, 2024
ef12621
Refactor DaoHierarchyNode to use transformNode function for improved …
Da-Colon Nov 22, 2024
232a875
Merge branch 'develop' into issue/2529-cache-it
Da-Colon Nov 22, 2024
55a4cd4
add cache version
Da-Colon Nov 23, 2024
5707413
add new DAOInfo typing
Da-Colon Nov 26, 2024
638640e
refactor: update DAOInfo structure and improve type handling in SafeC…
Da-Colon Nov 26, 2024
7fa5c29
refactor: replace nodeHierarchy with subgraphInfo in DAO components a…
Da-Colon Nov 26, 2024
ebe87c1
refactor: remove unused hooks related to Fractal modules and DAO loading
Da-Colon Nov 26, 2024
3582df2
refactor: update useFractalNode to use subgraph queries and improve D…
Da-Colon Nov 26, 2024
0ca063c
refactor: rename fractalModules to daoModules and update related refe…
Da-Colon Nov 26, 2024
3c35f84
remove duplicate link component
Da-Colon Nov 26, 2024
e62aecb
refactor: simplify props structure in DAONodeInfoCard component
Da-Colon Nov 26, 2024
1f540b6
refactor: update useDaoInfoStore to utilize subgraphInfo and adjust r…
Da-Colon Nov 27, 2024
bd13066
refactor: remove unused setDecentModules call in useUpdateSafeData hook
Da-Colon Nov 27, 2024
b0ec5db
refactor: enhance useFractalNode to integrate safeAPI and decentModul…
Da-Colon Nov 27, 2024
24fc95a
refactor: update DaoHierarchyNode to improve data loading and error h…
Da-Colon Nov 27, 2024
779f296
remove comment, let it ride for now
Da-Colon Nov 27, 2024
2c0fdd7
Merge branch 'issue/2529-cache-it' into breakout-issue/typing-dao-info
Da-Colon Nov 27, 2024
20eee2d
clean up error UI
Da-Colon Nov 27, 2024
db056a2
refactor: replace Flex with Box in DAONodeInfoCard and improve layout…
Da-Colon Nov 27, 2024
51a2c84
refactor: inline props structure in DAONodeInfoCard component
Da-Colon Nov 27, 2024
aa11d66
feat: add voting strategies to DAO hierarchy and update DAONodeInfoCard
Da-Colon Nov 28, 2024
62fb574
fix: handle null node response in DaoHierarchyNode component
Da-Colon Nov 28, 2024
dd821a1
refactor: update layout of voting strategies in DAONodeInfoCard compo…
Da-Colon Nov 28, 2024
680e8dd
refactor: rename modules to modulesAddresses for clarity in DaoInfoSt…
Da-Colon Nov 28, 2024
588301d
refactor: rename daoModules to modules for consistency across compone…
Da-Colon Nov 28, 2024
4fe6a61
refactor: replace FractalModuleData with DecentModule for improved cl…
Da-Colon Nov 28, 2024
41bfc90
refactor: remove unused lookupModules import from useUpdateSafeData hook
Da-Colon Nov 28, 2024
a5fa7f2
Merge branch 'breakout-issue/typing-dao-info' of github.com:decentdao…
Da-Colon Nov 28, 2024
21f4de6
refactor: replace FractalModuleData with DecentModule in DaoHierarchy…
Da-Colon Nov 28, 2024
77881bf
refactor: rename modules variable to decentModules for improved clari…
Da-Colon Nov 28, 2024
782c53b
Merge branch 'breakout-issue/typing-dao-info' of github.com:decentdao…
Da-Colon Nov 28, 2024
730c57c
refactor: update DAO-related types to handle null values for improved…
Da-Colon Nov 29, 2024
003be47
refactor: update safeAddress handling to ensure null safety across ho…
Da-Colon Nov 29, 2024
ed0f426
refactor: remove null type from parentAddress for improved type safet…
Da-Colon Nov 29, 2024
5a9faf6
Merge branch 'breakout-issue/typing-dao-info' of github.com:decentdao…
Da-Colon Nov 30, 2024
f698f95
Merge pull request #2579 from decentdao/issue/2530-hierarchy-voting-s…
Da-Colon Dec 2, 2024
9b9bb42
Merge pull request #2574 from decentdao/breakout-issue/typing-dao-info
Da-Colon Dec 2, 2024
6a47c16
refactor: filter governanceTypes to remove duplicates in DaoHierarchy…
Da-Colon Dec 2, 2024
7d36a2e
Merge branch 'develop' of github.com:decentdao/decent-interface into …
Da-Colon Dec 2, 2024
67d1c1e
refactor: update daoSnapshotENS to subgraphInfo in ProposalsHome comp…
Da-Colon Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions src/components/DaoHierarchy/DaoHierarchyNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { Center, Flex, Icon, Link } from '@chakra-ui/react';
import { ArrowElbowDownRight } from '@phosphor-icons/react';
import { useEffect, useState } from 'react';
import { Link as RouterLink } from 'react-router-dom';
import { Address, getAddress } from 'viem';
import { Address } from 'viem';
import { useChainId } from 'wagmi';
import { DAO_ROUTES } from '../../constants/routes';
import { useLoadDAONode } from '../../hooks/DAO/loaders/useLoadDAONode';
import { CacheKeys } from '../../hooks/utils/cache/cacheDefaults';
import { setValue, getValue } from '../../hooks/utils/cache/useLocalStorage';
import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider';
import { useDaoInfoStore } from '../../store/daoInfo/useDaoInfoStore';
import { DaoInfo, WithError } from '../../types';
import { DaoHierarchyInfo, DaoInfo, WithError } from '../../types';
import { DAONodeInfoCard, NODE_HEIGHT_REM } from '../ui/cards/DAONodeInfoCard';
import { BarLoader } from '../ui/loaders/BarLoader';
/**
Expand All @@ -30,7 +30,7 @@ export function DaoHierarchyNode({
depth: number;
}) {
const { safe: currentSafe } = useDaoInfoStore();
const [hierarchyNode, setHierarchyNode] = useState<DaoInfo>();
const [hierarchyNode, setHierarchyNode] = useState<DaoHierarchyInfo>();
const { addressPrefix } = useNetworkConfig();
const chainId = useChainId();
const { loadDao } = useLoadDAONode();
Expand All @@ -50,25 +50,26 @@ export function DaoHierarchyNode({
const errorNode = _node as WithError;
if (!errorNode.error) {
const fnode = _node as DaoInfo;
const theNode = {
daoName: fnode.daoName,
safeAddress: safeAddress,
fractalModules: fnode.fractalModules,
nodeHierarchy: {
parentAddress: fnode.nodeHierarchy.parentAddress,
childNodes: fnode.nodeHierarchy.childNodes,
},
};
setValue(
{
cacheName: CacheKeys.HIERARCHY_DAO_INFO,
chainId,
daoAddress: safeAddress,
},
fnode,
theNode,
);
setHierarchyNode(fnode);
setHierarchyNode(theNode);
} else if (errorNode.error === 'errorFailedSearch') {
setHierarchyNode({
daoName: null,
safe: null,
fractalModules: [],
nodeHierarchy: {
parentAddress: null,
childNodes: [],
},
});
setHierarchyNode(undefined);
}
});
}
Expand All @@ -88,12 +89,8 @@ export function DaoHierarchyNode({
);
}

const hierarchyNodeDAOAddress = hierarchyNode?.safe?.address;
if (!hierarchyNodeDAOAddress) {
throw new Error('Hierarchy node DAO address is missing');
}
const isCurrentViewingDAO =
currentSafe?.address.toLowerCase() === hierarchyNodeDAOAddress.toLocaleLowerCase();
currentSafe?.address.toLowerCase() === hierarchyNode.safeAddress.toLocaleLowerCase();
return (
<Flex
flexDirection="column"
Expand All @@ -103,7 +100,7 @@ export function DaoHierarchyNode({
>
<Link
Da-Colon marked this conversation as resolved.
Show resolved Hide resolved
as={RouterLink}
to={DAO_ROUTES.dao.relative(addressPrefix, hierarchyNodeDAOAddress)}
to={DAO_ROUTES.dao.relative(addressPrefix, hierarchyNode.safeAddress)}
_hover={{ textDecoration: 'none', cursor: isCurrentViewingDAO ? 'default' : 'pointer' }}
onClick={event => {
if (isCurrentViewingDAO) {
Expand All @@ -113,8 +110,8 @@ export function DaoHierarchyNode({
>
<DAONodeInfoCard
node={{
daoAddress: hierarchyNodeDAOAddress,
daoName: hierarchyNode?.daoName ?? getAddress(hierarchyNodeDAOAddress),
daoAddress: hierarchyNode.safeAddress,
daoName: hierarchyNode?.daoName ?? hierarchyNode.safeAddress,
daoSnapshotENS: hierarchyNode?.daoSnapshotENS,
}}
isCurrentViewingDAO={isCurrentViewingDAO}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/utils/cache/cacheDefaults.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address } from 'viem';
import { AzoriusProposal, DaoInfo } from '../../../types';
import { AzoriusProposal, DaoHierarchyInfo } from '../../../types';

export interface IStorageValue {
// the value to store, 1 character to minimize cache size
Expand Down Expand Up @@ -104,7 +104,7 @@ type CacheKeyToValueMap = {
[CacheKeys.AVERAGE_BLOCK_TIME]: number;
[CacheKeys.MIGRATION]: number;
[CacheKeys.IPFS_HASH]: string;
[CacheKeys.HIERARCHY_DAO_INFO]: DaoInfo;
[CacheKeys.HIERARCHY_DAO_INFO]: DaoHierarchyInfo;
};

export type CacheValueType<T extends CacheKeyType> = T extends { cacheName: infer U }
Expand Down
7 changes: 7 additions & 0 deletions src/types/fractal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ export interface DaoInfo extends SubgraphDAOInfo {
isModulesLoaded?: boolean;
}

export interface DaoHierarchyInfo {
daoName: string | null;
nodeHierarchy: NodeHierarchy;
Da-Colon marked this conversation as resolved.
Show resolved Hide resolved
safeAddress: Address;
daoSnapshotENS?: string;
}

export interface FractalModuleData {
moduleAddress: Address;
moduleType: FractalModuleType;
Expand Down