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

Release updates #33

Merged
merged 9 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions app/delegate/page.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Metadata } from 'next';
import React from 'react';

import { DelegatePage } from '../../src/delegate/components/DelegatePage';
import { ComingSoonPage } from '../../src/ui/pages/ComingSoonPage';
import { metaTexts } from '../../src/ui/utils/metaTexts';

export const metadata: Metadata = {
Expand All @@ -16,6 +15,5 @@ export const metadata: Metadata = {
};

export default function Page() {
// return <DelegatePage />;
return <ComingSoonPage />;
return <DelegatePage />;
}
161 changes: 84 additions & 77 deletions app/page.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import {
getGovCoreConfigs,
} from '@bgd-labs/aave-governance-ui-helpers';
import { Metadata } from 'next';
import React from 'react';

import { ProposalPageSSR } from '../src/proposals/components/proposalList/ProposalPageSSR';
import { ComingSoonPage } from '../src/ui/pages/ComingSoonPage';
import { metaTexts } from '../src/ui/utils/metaTexts';
import { appConfig } from '../src/utils/appConfig';
import { githubStartUrl, listViewPath } from '../src/utils/cacheGithubLinks';
Expand Down Expand Up @@ -37,80 +35,89 @@ export default async function Page({
}: {
searchParams: { [key: string]: string | string[] | undefined };
}) {
// const activePage = !!searchParams['activePage']
// ? Number(searchParams['activePage']) - 1
// : 0;
//
// const res = await fetch(`${githubStartUrl}/${listViewPath}`);
// const data = res.ok
// ? ((await res.json()) as PageServerSideData)
// : ({ totalProposalCount: -1, proposals: [] } as PageServerSideData);
// const cachedIds = data.proposals.map((data) => data.id);
// const totalIds =
// data.totalProposalCount >= 0
// ? Array.from(Array(data.totalProposalCount).keys()).sort((a, b) => b - a)
// : [];
// const startIndex = activePage * 10; // PAGE_SIZE
// let endIndex = startIndex + 10; // PAGE_SIZE
//
// if (endIndex > totalIds.length) {
// endIndex = totalIds.length;
// }
// const idsByPage = totalIds.slice(startIndex, endIndex);
//
// const activeIds: number[] = [];
// for (let i = 0; i < idsByPage.length; i++) {
// let found = false;
// for (let j = 0; j < cachedIds.length; j++) {
// if (idsByPage[i] === cachedIds[j]) {
// found = true;
// break;
// }
// }
//
// if (!found) {
// activeIds.push(idsByPage[i]);
// }
// }
//
// const cachedIdsByPage: number[] = [];
// for (let i = 0; i < idsByPage.length; i++) {
// let found = false;
// for (let j = 0; j < activeIds.length; j++) {
// if (idsByPage[i] === activeIds[j]) {
// found = true;
// break;
// }
// }
//
// if (!found) {
// cachedIdsByPage.push(idsByPage[i]);
// }
// }
//
// const { configs, contractsConstants } = await getGovCoreConfigs({
// client: initialClients[appConfig.govCoreChainId],
// govCoreContractAddress: appConfig.govCoreConfig.contractAddress,
// govCoreDataHelperContractAddress:
// appConfig.govCoreConfig.dataHelperContractAddress,
// });
//
// const cachedProposalsData = cachedIdsByPage.map((id) => {
// const proposal = data.proposals.filter((proposal) => proposal.id === id)[0];
//
// return {
// id: proposal.id,
// proposal: {
// data: {
// id: proposal.id,
// finishedTimestamp: proposal.finishedTimestamp,
// title: proposal.title,
// ipfsHash: proposal.ipfsHash,
// },
// state: proposal.state,
// },
// } as CachedProposalDataItemWithId;
// });
const activePage = !!searchParams['activePage']
? Number(searchParams['activePage']) - 1
: 0;

return <ComingSoonPage />;
const res = await fetch(`${githubStartUrl}/${listViewPath}`);
const data = res.ok
? ((await res.json()) as PageServerSideData)
: ({ totalProposalCount: -1, proposals: [] } as PageServerSideData);
const cachedIds = data.proposals.map((data) => data.id);
const totalIds =
data.totalProposalCount >= 0
? Array.from(Array(data.totalProposalCount).keys()).sort((a, b) => b - a)
: [];
const startIndex = activePage * 10; // PAGE_SIZE
let endIndex = startIndex + 10; // PAGE_SIZE

if (endIndex > totalIds.length) {
endIndex = totalIds.length;
}
const idsByPage = totalIds.slice(startIndex, endIndex);

const activeIds: number[] = [];
for (let i = 0; i < idsByPage.length; i++) {
let found = false;
for (let j = 0; j < cachedIds.length; j++) {
if (idsByPage[i] === cachedIds[j]) {
found = true;
break;
}
}

if (!found) {
activeIds.push(idsByPage[i]);
}
}

const cachedIdsByPage: number[] = [];
for (let i = 0; i < idsByPage.length; i++) {
let found = false;
for (let j = 0; j < activeIds.length; j++) {
if (idsByPage[i] === activeIds[j]) {
found = true;
break;
}
}

if (!found) {
cachedIdsByPage.push(idsByPage[i]);
}
}

const { configs, contractsConstants } = await getGovCoreConfigs({
client: initialClients[appConfig.govCoreChainId],
govCoreContractAddress: appConfig.govCoreConfig.contractAddress,
govCoreDataHelperContractAddress:
appConfig.govCoreConfig.dataHelperContractAddress,
});

const cachedProposalsData = cachedIdsByPage.map((id) => {
const proposal = data.proposals.filter((proposal) => proposal.id === id)[0];

return {
id: proposal.id,
proposal: {
data: {
id: proposal.id,
finishedTimestamp: proposal.finishedTimestamp,
title: proposal.title,
ipfsHash: proposal.ipfsHash,
},
state: proposal.state,
},
} as CachedProposalDataItemWithId;
});

return (
<ProposalPageSSR
cachedProposals={data.proposals}
cachedTotalProposalCount={data.totalProposalCount}
govCoreConfigs={configs}
contractsConstants={contractsConstants}
cachedProposalsData={cachedProposalsData}
cachedActiveIds={activeIds}
/>
);
}
19 changes: 0 additions & 19 deletions app/proposal-create-overview-v2/page.page.tsx

This file was deleted.

Loading