Skip to content

Commit fac8803

Browse files
committed
chore(insights): responed to PR feedback
1 parent 459f7b1 commit fac8803

File tree

4 files changed

+16
-48
lines changed

4 files changed

+16
-48
lines changed

apps/insights/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"next-themes": "catalog:",
5151
"@pythnetwork/react-hooks": "workspace:",
5252
"papaparse": "catalog:",
53-
"query-string": "catalog:",
5453
"react": "catalog:",
5554
"react-aria": "catalog:",
5655
"react-aria-components": "catalog:",

apps/insights/src/hooks/pyth-pro-demo/use-http-datastream.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useAlert } from "@pythnetwork/component-library/useAlert";
22
import type { Nullish } from "@pythnetwork/shared-lib/types";
33
import { wait } from "@pythnetwork/shared-lib/util";
4-
import qs from "query-string";
54
import { useEffect, useRef, useState } from "react";
65

76
import type {
@@ -46,15 +45,14 @@ function getFetchHistoricalUrl(
4645
return "";
4746
}
4847

49-
const query = qs.stringify(
50-
{
51-
datasources,
52-
startAt: startAtValidation.data.toISOString(),
53-
},
54-
{ arrayFormat: "bracket" },
55-
);
48+
const queryParams = new URLSearchParams();
49+
queryParams.set("startAt", startAtValidation.data.toISOString());
50+
51+
for (const datasource of datasources) {
52+
queryParams.append("datasources[]", datasource);
53+
}
5654

57-
return `/api/pyth/get-pyth-feeds-demo-data/${removeReplaySymbolSuffix(symbol)}?${query}`;
55+
return `/api/pyth/get-pyth-feeds-demo-data/${removeReplaySymbolSuffix(symbol)}?${queryParams.toString()}`;
5856
}
5957

6058
export async function fetchHistoricalData(
@@ -124,10 +122,16 @@ export function useHttpDataStream({
124122
});
125123

126124
useEffect(() => {
127-
if (!enabled || !isReplaySymbol(symbol)) return;
125+
if (!enabled || !isReplaySymbol(symbol)) {
126+
setStatus("closed");
127+
return;
128+
}
128129

129130
const url = getFetchHistoricalUrl(dataSources, symbol, startAtToFetch);
130-
if (!url) return;
131+
if (!url) {
132+
setStatus("closed");
133+
return;
134+
}
131135

132136
setStatus("connected");
133137

@@ -138,7 +142,7 @@ export function useHttpDataStream({
138142
// this may mean that one data source runs further ahead than another for a bit,
139143
// if there is no data for a certain time interval
140144

141-
for (let i = 0; i < data.length - 1; i++) {
145+
for (let i = 0; i < data.length; i++) {
142146
const currPoint = data[i];
143147
const nextPoint = data[i + 1];
144148

pnpm-lock.yaml

Lines changed: 0 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ catalog:
156156
prettier-plugin-solidity: ^1.4.2
157157
prompts: 2.4.2
158158
proxycheck-ts: ^0.0.11
159-
query-string: ^9.3.1
160159
react: ^19.1.4
161160
react-aria: ^3.42.0
162161
react-aria-components: ^1.11.0

0 commit comments

Comments
 (0)