Skip to content

Commit

Permalink
chore: improve landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
Anonymous committed Sep 11, 2024
1 parent ff7de8a commit 91930e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/frontend/src/landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Metadata, Order } from "./types";
import readme from "../../../README.md";

const immutabilityDate = new Date("2024-10-01");
const maxTokensShown = 10;

export const Landing = ({}) => {
const [orders, setOrders] = React.useState<{ [name: string]: Order }>({});
Expand All @@ -24,7 +25,7 @@ export const Landing = ({}) => {
"prices",
);
if (orders) setOrders(orders);
setShortenList(Object.keys(window.tokenData).length > 5);
setShortenList(Object.keys(window.tokenData).length > maxTokensShown);
};

React.useEffect(() => {
Expand All @@ -42,10 +43,14 @@ export const Landing = ({}) => {
active_traders,
} = window.data;

const timestamp = (id: string) => (id in orders ? orders[id].timestamp : 0);
const timestamp = (id: string, md: Metadata) =>
id in orders ? 10 * orders[id].timestamp : md.timestamp;
const tokenList = (inputs: [string, Metadata][]) => {
inputs.sort(([id1], [id2]) => timestamp(id2) - timestamp(id1));
return shortenList ? inputs.slice(0, 5) : inputs;
inputs.sort(
([id1, md1], [id2, md2]) =>
timestamp(id2, md2) - timestamp(id1, md1),
);
return shortenList ? inputs.slice(0, maxTokensShown) : inputs;
};

return (
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type Metadata = {
fee: bigint;
decimals: number;
logo: string;
timestamp: number;
};

export enum OrderType {
Expand Down

0 comments on commit 91930e1

Please sign in to comment.