Browse Source

chore: replace `window` with `globalThis`

Connor Prussin 8 months ago
parent
commit
faff98dfd5

+ 1 - 1
apps/insights/src/components/PriceComponentDrawer/index.tsx

@@ -337,7 +337,7 @@ const getScoreHistory = async ([
   symbol,
   selectedPeriod,
 ]: [Cluster, string, string, EvaluationPeriod]) => {
-  const url = new URL("/component-score-history", window.location.origin);
+  const url = new URL("/component-score-history", globalThis.location.origin);
   url.searchParams.set("cluster", ClusterToName[cluster]);
   url.searchParams.set("publisherKey", publisherKey);
   url.searchParams.set("symbol", symbol);

+ 1 - 1
apps/insights/src/components/PriceFeed/chart.tsx

@@ -44,7 +44,7 @@ const useChartElem = (symbol: string, feedId: string) => {
   const backfillData = useCallback(() => {
     if (!isBackfilling.current && earliestDateRef.current) {
       isBackfilling.current = true;
-      const url = new URL("/historical-prices", window.location.origin);
+      const url = new URL("/historical-prices", globalThis.location.origin);
       url.searchParams.set("symbol", symbol);
       url.searchParams.set("until", earliestDateRef.current.toString());
       fetch(url)

+ 1 - 1
apps/insights/src/components/PriceFeedChangePercent/index.tsx

@@ -43,7 +43,7 @@ export const YesterdaysPricesProvider = ({
 const getYesterdaysPrices = async (
   feeds: YesterdaysPricesProviderProps["feeds"],
 ): Promise<Map<string, number>> => {
-  const url = new URL("/yesterdays-prices", window.location.origin);
+  const url = new URL("/yesterdays-prices", globalThis.location.origin);
   for (const symbol of Object.keys(feeds)) {
     url.searchParams.append("symbols", symbol);
   }

+ 2 - 2
apps/insights/src/components/Root/search-dialog.tsx

@@ -434,9 +434,9 @@ const useSearchDialogStateContext = () => {
   );
 
   useEffect(() => {
-    window.addEventListener("keydown", handleKeyDown);
+    globalThis.addEventListener("keydown", handleKeyDown);
     return () => {
-      window.removeEventListener("keydown", handleKeyDown);
+      globalThis.removeEventListener("keydown", handleKeyDown);
     };
   }, [handleKeyDown]);
 

+ 1 - 1
apps/staking/src/components/Root/i18n-provider.tsx

@@ -16,7 +16,7 @@ export const I18nProvider = (
     () =>
       isSSR
         ? DEFAULT_LOCALE
-        : (window.navigator.languages.find((locale) => {
+        : (globalThis.navigator.languages.find((locale) => {
             const language = parse(locale).language;
             return (
               language !== undefined &&

+ 1 - 1
packages/next-root/src/i18n-provider.tsx

@@ -16,7 +16,7 @@ export const I18nProvider = (
     () =>
       isSSR
         ? DEFAULT_LOCALE
-        : (window.navigator.languages.find((locale) => {
+        : (globalThis.navigator.languages.find((locale) => {
             const language = parse(locale).language;
             return (
               language !== undefined &&