Skip to content

Commit

Permalink
fix: voters requests and remove winter styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Argeare5 committed Jan 10, 2024
1 parent d65527a commit 829a316
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 118 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@bgd-labs/aave-address-book": "^2.13.3",
"@bgd-labs/aave-governance-ui-helpers": "^1.0.16",
"@bgd-labs/aave-governance-ui-helpers": "^1.0.17",
"@bgd-labs/frontend-web3-utils": "^1.0.4",
"@emotion/cache": "^11.11.0",
"@emotion/react": "^11.11.3",
Expand Down Expand Up @@ -72,7 +72,6 @@
"react-final-form-arrays": "^3.1.4",
"react-loading-skeleton": "^3.3.1",
"react-paginate": "^8.2.0",
"react-snowfall": "^1.2.1",
"sharp": "^0.32.6",
"viem": "^1.19.15",
"wagmi": "^1.4.12",
Expand Down
9 changes: 8 additions & 1 deletion public/images/networks/metis.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/proposals/components/ProposalEstimatedStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export function ProposalEstimatedStatus({
<Timer
timestamp={timestamp}
callbackFuncWhenTimerFinished={() =>
!isForHelpModal && getDetailedProposalsData([proposalId])
!isForHelpModal &&
getDetailedProposalsData({ ids: [proposalId], fullData: true })
}
/>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/proposals/components/proposal/ProposalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function ProposalPage({
const totalVotes = forVotes + againstVotes;

if (startBlock > 0) {
if (totalVotes > 0 && !proposal.data.prerender) {
if (totalVotes > 0 && !proposal.data.prerender && isVotingActive) {
getVoters(
proposal.data.id,
proposal.data.votingChainId,
Expand Down
146 changes: 90 additions & 56 deletions src/proposals/store/proposalsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,19 @@ export interface IProposalsSlice {
setDetailedProposalsDataLoadings: (id: number) => void;
detailedProposalsDataLoading: boolean;
setDetailedProposalsData: (id: number, data: ProposalData) => void;
getDetailedProposalsData: (
ids: number[],
from?: number,
to?: number,
pageSize?: number,
) => void;
getDetailedProposalsData: ({
ids,
from,
to,
pageSize,
fullData,
}: {
ids: number[];
from?: number;
to?: number;
pageSize?: number;
fullData?: boolean;
}) => Promise<void>;
detailedProposalDataInterval: number | undefined;
startDetailedProposalDataPolling: (ids?: number[]) => Promise<void>;
stopDetailedProposalDataPolling: () => void;
Expand Down Expand Up @@ -318,7 +325,7 @@ export const createProposalsSlice: StoreSlice<
}
const paginatedIds = selectPaginatedIds(get());
const { activeIds } = selectProposalIds(get(), paginatedIds);
await get().getDetailedProposalsData(activeIds);
await get().getDetailedProposalsData({ ids: activeIds });
if (!!activeIds.length) {
await Promise.allSettled([
await get().getIpfsData(activeIds),
Expand All @@ -330,7 +337,7 @@ export const createProposalsSlice: StoreSlice<
} else {
const paginatedIds = selectPaginatedIds(get());
const { activeIds } = selectProposalIds(get(), paginatedIds);
await get().getDetailedProposalsData(activeIds);
await get().getDetailedProposalsData({ ids: activeIds });
await Promise.allSettled([
await get().getIpfsData(activeIds),
await get().getL1Balances(activeIds),
Expand All @@ -341,7 +348,7 @@ export const createProposalsSlice: StoreSlice<
getPaginatedProposalsDataWithoutIpfs: async () => {
const paginatedIds = selectPaginatedIds(get());
const { activeIds } = selectProposalIds(get(), paginatedIds);
await get().getDetailedProposalsData(activeIds);
await get().getDetailedProposalsData({ ids: activeIds });
await get().getL1Balances(activeIds);
get().updatePaginatedProposalsData();
},
Expand Down Expand Up @@ -374,7 +381,7 @@ export const createProposalsSlice: StoreSlice<
);
},
getProposalDataWithIpfsById: async (id) => {
await get().getDetailedProposalsData([id]);
await get().getDetailedProposalsData({ ids: [id] });
await Promise.allSettled([
await get().getIpfsData([id]),
await get().getL1Balances([id]),
Expand Down Expand Up @@ -540,7 +547,7 @@ export const createProposalsSlice: StoreSlice<
}
},

getDetailedProposalsData: async (ids, from, to, pageSize) => {
getDetailedProposalsData: async ({ ids, from, to, pageSize, fullData }) => {
const userAddress = get().activeWallet?.address;
const representativeAddress = get().representative.address;

Expand Down Expand Up @@ -568,19 +575,23 @@ export const createProposalsSlice: StoreSlice<

const timeToUpdate = dayjs().unix() + 3 * 1000 * 50; // now + 3 minutes;

const filteredIds = ids.filter((id) => {
return !get().detailedProposalsData[id]
? true
: (get().detailedProposalsData[id]?.lastUpdatedTimestamp || 0) >
timeToUpdate;
});
const filteredIds = fullData
? ids
: ids.filter((id) => {
return !get().detailedProposalsData[id]
? true
: (get().detailedProposalsData[id]?.lastUpdatedTimestamp || 0) >
timeToUpdate;
});

const idsForUpdateVotingInfo = ids.filter((id) => {
return !get().detailedProposalsData[id]
? false
: (get().detailedProposalsData[id]?.lastUpdatedTimestamp || 0) <
timeToUpdate;
});
const isUpdateOnlyVotingPower = fullData
? !![].length
: !!ids.filter((id) => {
return !get().detailedProposalsData[id]
? false
: (get().detailedProposalsData[id]?.lastUpdatedTimestamp || 0) <
timeToUpdate;
}).length;

let proposalsData: BasicProposal[] = [];
if (!!filteredIds.length && isProposalNotInCache) {
Expand Down Expand Up @@ -623,7 +634,7 @@ export const createProposalsSlice: StoreSlice<
PAGE_SIZE,
get().setRpcError,
);
} else if (!isProposalNotInCache || !!idsForUpdateVotingInfo.length) {
} else if (!isProposalNotInCache || isUpdateOnlyVotingPower) {
const proposals = ids.map((id) => get().detailedProposalsData[id]);
proposalsData = await get().govDataService.getOnlyVotingMachineData(
get().configs,
Expand All @@ -648,33 +659,53 @@ export const createProposalsSlice: StoreSlice<
.flat()
.filter((value, index, self) => self.indexOf(value) === index);

await Promise.all(
payloadsChainIds.map(async (chainId) => {
await Promise.all(
payloadsControllers.map(async (controller) => {
const payloadsIds = proposalsData
.map((proposal) =>
proposal.initialPayloads.filter(
(payload) =>
payload.chainId === chainId &&
payload.payloadsController === controller,
),
)
.flat()
.map((payload) => payload.id);

if (isProposalNotInCache) {
await get().getDetailedPayloadsData(
chainId,
controller,
payloadsIds,
);
}
}),
);
}),
const allPayloadsLength = Object.values(
get().detailedPayloadsData,
).length;
console.log(Object.values(get().detailedPayloadsData));
console.log('allPayloadsLength', allPayloadsLength);
console.log(
proposalsData.map((value) => value.initialPayloads).flat().length,
);
console.log('allPayloadsLength', allPayloadsLength);
console.log(
allPayloadsLength <
proposalsData.map((value) => value.initialPayloads).flat().length,
);

if (
(!!payloadsChainIds.length && !isUpdateOnlyVotingPower) ||
allPayloadsLength <
proposalsData.map((value) => value.initialPayloads).flat().length
) {
await Promise.allSettled(
payloadsChainIds.map(async (chainId) => {
await Promise.allSettled(
payloadsControllers.map(async (controller) => {
const payloadsIds = proposalsData
.map((proposal) =>
proposal.initialPayloads.filter(
(payload) =>
payload.chainId === chainId &&
payload.payloadsController === controller,
),
)
.flat()
.map((payload) => payload.id);

if (isProposalNotInCache) {
await get().getDetailedPayloadsData(
chainId,
controller,
payloadsIds,
);
}
}),
);
}),
);
}

const proposalPayloadsData = proposalsData.map((proposal) => {
const payloads = proposal.initialPayloads.map((payload) => {
return {
Expand Down Expand Up @@ -743,8 +774,11 @@ export const createProposalsSlice: StoreSlice<
const activeProposalsIds = !!ids?.length ? ids : activeIds;

if (!!activeProposalsIds.length) {
await get().getDetailedProposalsData(activeProposalsIds);
await Promise.all([
await get().getDetailedProposalsData({
ids: activeProposalsIds,
fullData: true,
});
await Promise.allSettled([
await get().getIpfsData(activeProposalsIds),
await get().getL1Balances(activeProposalsIds),
]);
Expand Down Expand Up @@ -776,11 +810,11 @@ export const createProposalsSlice: StoreSlice<
const currentProposalCount = get().totalProposalCount;

if (totalProposalCountFromContract > currentProposalCount) {
get().getDetailedProposalsData(
[],
currentProposalCount,
currentProposalCount - 1,
);
await get().getDetailedProposalsData({
ids: [],
from: currentProposalCount,
to: currentProposalCount - 1,
});
get().setTotalProposalCount(totalProposalCountFromContract);
}
}, 15000);
Expand Down
5 changes: 4 additions & 1 deletion src/transactions/store/transactionsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ export const createTransactionsSlice: StoreSlice<
...createBaseTransactionsSlice<TransactionUnion>({
txStatusChangedCallback: async (data) => {
const updateProposalData = async (proposalId: number) => {
get().getDetailedProposalsData([proposalId]);
await get().getDetailedProposalsData({
ids: [proposalId],
fullData: true,
});
};

switch (data.type) {
Expand Down
31 changes: 7 additions & 24 deletions src/ui/layouts/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { usePathname } from 'next/navigation';
import React, { useEffect, useRef, useState } from 'react';

import WarningIcon from '/public/images/icons/warningIcon.svg';
import Logo from '/public/images/winter_logo.svg';
import Logo from '/public/images/logo.svg';

import { selectIsRpcAppHasErrors } from '../../rpcSwitcher/store/rpcSwitcherSelectors';
import { useStore } from '../../store';
Expand Down Expand Up @@ -211,35 +211,18 @@ export function AppHeader() {
}}>
<IconBox
sx={{
// width: 59,
// height: 26,
// [theme.breakpoints.up('lg')]: {
// width: 80,
// height: 35,
// },
// '> svg': {
// width: 59,
// height: 26,
// [theme.breakpoints.up('lg')]: {
// width: 80,
// height: 35,
// },
// },
width: 65,
height: 34,
position: 'relative',
bottom: 3,
width: 59,
height: 26,
[theme.breakpoints.up('lg')]: {
width: 80,
height: 44,
bottom: 4,
height: 35,
},
'> svg': {
width: 65,
height: 34,
width: 59,
height: 26,
[theme.breakpoints.up('lg')]: {
width: 80,
height: 44,
height: 35,
},
},
}}>
Expand Down
10 changes: 0 additions & 10 deletions src/ui/layouts/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'nprogress/nprogress.css';
import Router from 'next/router';
import NProgress from 'nprogress';
import React, { useEffect } from 'react';
import Snowfall from 'react-snowfall';

import { RepresentationInfoModal } from '../../representations/components/RepresentationInfoModal';
import { useStore } from '../../store';
Expand Down Expand Up @@ -36,15 +35,6 @@ export default function AppLayout({ children }: { children: React.ReactNode }) {
<>
<Web3HelperProvider />

<Snowfall
snowflakeCount={30}
style={{
position: 'fixed',
width: '100vw',
height: '100vh',
}}
/>

<MainLayout>{children}</MainLayout>

<HelpModalProvider />
Expand Down
12 changes: 6 additions & 6 deletions src/ui/pages/CreateProposalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export function CreateProposalPage() {
}, []);

useEffect(() => {
getDetailedProposalsData(
[],
0,
undefined,
totalProposalCount >= 0 ? totalProposalCount : 1,
);
getDetailedProposalsData({
ids: [],
from: 0,
pageSize: totalProposalCount >= 0 ? totalProposalCount : 1,
fullData: true,
});
}, [totalProposalCount]);

return (
Expand Down
Loading

1 comment on commit 829a316

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

Please sign in to comment.