From d74636af62cef7bd75e50ecaa51474d3e05cb38e Mon Sep 17 00:00:00 2001 From: arkin0x Date: Sat, 28 Oct 2023 23:40:04 -0500 Subject: [PATCH] fix ts --- src/components/App.tsx | 14 +++++++++----- src/components/Game.tsx | 2 +- src/components/Pico8Game.tsx | 1 + src/components/Retrieve.tsx | 2 +- src/libraries/PublishGame.tsx | 1 + 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 43db549..f55ea35 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useEffect, useState } from 'react' import { BrowserRouter as Router, Route, Routes } from 'react-router-dom' import { Home } from './Home' import { Publish } from './Publish' @@ -9,12 +9,16 @@ import { Retrieve } from './Retrieve' import { Header } from './Header' import { Game } from './Game' -if (window.nostr){ - await window.nostr.getPublicKey() -} - export const App = () => { const [playing, setPlaying] = useState(false) + useEffect(() => { + const connect = async () => { + if (window.nostr){ + await window.nostr.getPublicKey() + } + } + connect() + },[]) return ( <>
diff --git a/src/components/Game.tsx b/src/components/Game.tsx index 0539327..3d7d7f9 100644 --- a/src/components/Game.tsx +++ b/src/components/Game.tsx @@ -2,6 +2,6 @@ import { useParams } from "react-router-dom" import { Retrieve } from "./Retrieve" export const Game: React.FC<{setPlaying: React.Dispatch>}> = ({setPlaying}) => { - const { id }: { id?: string } = useParams<{ uuid?: string }>() + const { id }: { id?: string } = useParams<{ id?: string }>() return } \ No newline at end of file diff --git a/src/components/Pico8Game.tsx b/src/components/Pico8Game.tsx index f893b3a..07826ef 100644 --- a/src/components/Pico8Game.tsx +++ b/src/components/Pico8Game.tsx @@ -987,6 +987,7 @@ export const Pico8Game = ({ gameJS, setPlaying }: { gameJS: string, setPlaying: // probably just refresh the page... but when? initializeWindow(); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [gameJS]); return ( diff --git a/src/components/Retrieve.tsx b/src/components/Retrieve.tsx index 9998ed4..bd364f1 100644 --- a/src/components/Retrieve.tsx +++ b/src/components/Retrieve.tsx @@ -55,7 +55,7 @@ export const Retrieve: React.FC<{setPlaying: React.Dispatch { - console.log('fetching game by uuid', uuid) + if (!ndk) return const gameFilter: NDKFilter = { "#u": [uuid], "kinds": [1] } const games = Array.from(await ndk.fetchEvents(gameFilter)) if (games.length === 0) { diff --git a/src/libraries/PublishGame.tsx b/src/libraries/PublishGame.tsx index c053118..9426e52 100644 --- a/src/libraries/PublishGame.tsx +++ b/src/libraries/PublishGame.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react-refresh/only-export-components */ import NDK, { NDKEvent } from '@nostr-dev-kit/ndk' import { v4 as uuidv4 } from 'uuid'; // import { html, js } from '../assets/ExampleGameHTMLJS.ts'