From bc7fdf808968ecec76a7a1e90f6c63f93339fb99 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Tue, 2 Mar 2021 19:02:20 +0200 Subject: [PATCH] performance: debloat redux store --- packages/concordia-app/package.json | 2 +- .../components/PostList/PostListRow/index.jsx | 6 ++- .../components/PostList/PostVoting/index.jsx | 6 ++- .../TopicList/TopicListRow/index.jsx | 6 ++- .../src/components/UsernameSelector.jsx | 6 ++- .../MainLayoutConcordiaStatus/index.jsx | 50 ++++--------------- .../concordia-app/src/views/Home/index.jsx | 18 ++++++- .../concordia-app/src/views/Profile/index.jsx | 24 ++++++++- .../Topic/TopicView/TopicPostList/index.jsx | 6 ++- .../concordia-contracts/contracts/Forum.sol | 9 ++++ .../contracts/PostVoting.sol | 8 +-- yarn.lock | 11 ++-- 12 files changed, 90 insertions(+), 62 deletions(-) diff --git a/packages/concordia-app/package.json b/packages/concordia-app/package.json index db994d8..54356c7 100644 --- a/packages/concordia-app/package.json +++ b/packages/concordia-app/package.json @@ -25,7 +25,7 @@ }, "dependencies": { "@ezerous/breeze": "~0.7.0", - "@ezerous/drizzle": "~0.4.3", + "@ezerous/drizzle": "~0.5.0", "@ezerous/eth-identity-provider": "~0.1.2", "@reduxjs/toolkit": "~1.4.0", "@welldone-software/why-did-you-render": "~6.0.5", diff --git a/packages/concordia-app/src/components/PostList/PostListRow/index.jsx b/packages/concordia-app/src/components/PostList/PostListRow/index.jsx index ee438cb..3655066 100644 --- a/packages/concordia-app/src/components/PostList/PostListRow/index.jsx +++ b/packages/concordia-app/src/components/PostList/PostListRow/index.jsx @@ -13,7 +13,7 @@ import { Link } from 'react-router-dom'; import { FORUM_CONTRACT } from 'concordia-shared/src/constants/contracts/ContractNames'; import { POSTS_DATABASE, USER_DATABASE } from 'concordia-shared/src/constants/orbit/OrbitDatabases'; import { FETCH_USER_DATABASE } from '../../../redux/actions/peerDbReplicationActions'; -import { breeze } from '../../../redux/store'; +import { breeze, drizzle } from '../../../redux/store'; import determineKVAddress from '../../../utils/orbitUtils'; import { POST_CONTENT } from '../../../constants/orbit/PostsDatabaseKeys'; import ProfileImage from '../../ProfileImage'; @@ -23,6 +23,8 @@ import './styles.css'; const { orbit } = breeze; +const { contracts: { [FORUM_CONTRACT]: { methods: { getPost: { clearCacheCall: clearGetPostChainData } } } } } = drizzle; + const PostListRow = (props) => { const { id: postId, postIndex, postCallHash, loading, focus, @@ -99,6 +101,8 @@ const PostListRow = (props) => { } }, [focus]); + useEffect(() => () => clearGetPostChainData(postId), [postId]); + return useMemo(() => ( { }, [ownVote, postId, userAccount, voting]); const disableVoting = userAccount === null || !hasSignedUp || postAuthorAddress === null || userAccount === postAuthorAddress; + + // Clear when unmounting + useEffect(() => () => clearGetVoteInfoChainData(postId), [postId]); + return useMemo(() => (