Skip to content

Commit fc4159b

Browse files
committed
Optimize payload size for price feeds pages
1 parent c6a2eb9 commit fc4159b

File tree

24 files changed

+371
-259
lines changed

24 files changed

+371
-259
lines changed

apps/insights/src/app/layout.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export { Root as default } from "../components/Root";
22
export { metadata, viewport } from "../metadata";
33

4+
export const dynamic = "error";
45
export const revalidate = 3600;

apps/insights/src/app/price-feeds/[slug]/layout.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export const metadata: Metadata = {
66
title: "Price Feeds",
77
};
88

9+
export const dynamic = "error";
910
export const revalidate = 3600;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { ChartPage as default } from "../../../components/PriceFeed/chart-page";
22

3+
export const dynamic = "error";
34
export const revalidate = 3600;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { Publishers as default } from "../../../../components/PriceFeed/publishers";
22

3+
export const dynamic = "error";
34
export const revalidate = 3600;

apps/insights/src/app/price-feeds/page.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export const metadata: Metadata = {
66
title: "Price Feeds",
77
};
88

9+
export const dynamic = "error";
910
export const revalidate = 3600;

apps/insights/src/app/publishers/[key]/layout.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export const metadata: Metadata = {
66
title: "Publishers",
77
};
88

9+
export const dynamic = "error";
910
export const revalidate = 3600;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { Performance as default } from "../../../components/Publisher/performance";
22

3+
export const dynamic = "error";
34
export const revalidate = 3600;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { PriceFeeds as default } from "../../../../components/Publisher/price-feeds";
22

3+
export const dynamic = "error";
34
export const revalidate = 3600;

apps/insights/src/app/publishers/page.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export const metadata: Metadata = {
66
title: "Publishers",
77
};
88

9+
export const dynamic = "error";
910
export const revalidate = 3600;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Badge } from "@pythnetwork/component-library/Badge";
2+
import type { ComponentProps } from "react";
3+
4+
import { usePriceFeeds } from "../../hooks/use-price-feeds";
5+
6+
type Props = ComponentProps<typeof Badge> & {
7+
symbol: string;
8+
};
9+
10+
export const AssetClassTag = ({ symbol }: Props) => {
11+
const feed = usePriceFeeds().get(symbol);
12+
13+
if (feed) {
14+
return (
15+
<Badge variant="neutral" style="outline" size="xs">
16+
{feed.assetClass.toUpperCase()}
17+
</Badge>
18+
);
19+
} else {
20+
throw new NoSuchFeedError(symbol);
21+
}
22+
};
23+
24+
class NoSuchFeedError extends Error {
25+
constructor(symbol: string) {
26+
super(`No feed exists named ${symbol}`);
27+
this.name = "NoSuchFeedError";
28+
}
29+
}

0 commit comments

Comments
 (0)