diff --git a/src/App.tsx b/src/App.tsx index 4f18330..8ad25ac 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -65,7 +65,7 @@ function App() { useEffect(() => { ndk.connect().then(() => { - console.log('NDK connected', { ndk }) + console.log('NDK connected') setIsConnected(true) }) // eslint-disable-next-line diff --git a/src/components/Modal/ModalConfirmConnect/ModalConfirmConnect.tsx b/src/components/Modal/ModalConfirmConnect/ModalConfirmConnect.tsx index 8f254ae..fd72265 100644 --- a/src/components/Modal/ModalConfirmConnect/ModalConfirmConnect.tsx +++ b/src/components/Modal/ModalConfirmConnect/ModalConfirmConnect.tsx @@ -61,12 +61,23 @@ export const ModalConfirmConnect = () => { }, }) + // NOTE: when opened directly to this modal using authUrl, + // we might not have pending requests visible yet bcs we haven't + // loaded them yet, which means this modal will be closed with + // the logic below. So now if it's popup then we wait for SW + // and then wait a little more to give it time to fetch + // pending reqs from db. Same logic implemented in confirm-event. + + // FIXME move to a separate hook and reuse? + useEffect(() => { if (isModalOpened) { if (isPopup) { + console.log("waiting for sw") // wait for SW to start swicWaitStarted().then(() => { // give it some time to load the pending reqs etc + console.log("waiting for sw done") setTimeout(() => setIsLoaded(true), 500) }) } else { @@ -75,7 +86,7 @@ export const ModalConfirmConnect = () => { } else { setIsLoaded(false) } - }, [isModalOpened]) + }, [isModalOpened, isPopup]) if (isLoaded) { const isNpubExists = npub.trim().length && keys.some((key) => key.npub === npub) @@ -88,8 +99,6 @@ export const ModalConfirmConnect = () => { else closeModalAfterRequest() return null } - // reset - setIsLoaded(false) } const handleActionTypeChange = (_: any, value: ACTION_TYPE | null) => { @@ -208,7 +217,7 @@ export const ModalConfirmConnect = () => { - Disallow + Ignore Connect diff --git a/src/components/Modal/ModalConfirmEvent/ModalConfirmEvent.tsx b/src/components/Modal/ModalConfirmEvent/ModalConfirmEvent.tsx index bc99ae3..cc0f01f 100644 --- a/src/components/Modal/ModalConfirmEvent/ModalConfirmEvent.tsx +++ b/src/components/Modal/ModalConfirmEvent/ModalConfirmEvent.tsx @@ -76,20 +76,7 @@ export const ModalConfirmEvent: FC = ({ confirmEventReqs } else { setIsLoaded(false) } - }, [isModalOpened]) - - // FIXME: when opened directly to this modal using authUrl, - // we might not have pending requests visible yet bcs we haven't - // loaded them yet, which means this modal will be closed with - // the logic below. It's fine if only one app has sent pending - // requests atm, bcs the modal would re-appear as soon as we load - // the requests. But if there are several pending reqs from other - // apps then popup might show a different one! Which is very - // contrary to what user expects. So: - // - if isPopup - dont close the modal with logic below - // - show some 'loading' indicator until we've got some requests - // for the specified appNpub - // FIXME is the same logic valid for Connect modal? + }, [isModalOpened, isPopup]) if (isLoaded) { const isNpubExists = npub.trim().length && keys.some((key) => key.npub === npub) @@ -100,8 +87,6 @@ export const ModalConfirmEvent: FC = ({ confirmEventReqs else closeModalAfterRequest() return null } - // reset - setIsLoaded(false) } const triggerApp = apps.find((app) => app.appNpub === appNpub) diff --git a/src/hooks/useModalSearchParams.ts b/src/hooks/useModalSearchParams.ts index f935c15..f1cbf3e 100644 --- a/src/hooks/useModalSearchParams.ts +++ b/src/hooks/useModalSearchParams.ts @@ -31,7 +31,7 @@ export const useModalSearchParams = () => { const enumKey = getEnumParam(modal) searchParams.delete(enumKey) extraOptions?.onClose && extraOptions?.onClose(searchParams) - console.log({ searchParams }) + // console.log({ searchParams }) setSearchParams(searchParams, { replace: !!extraOptions?.replace }) }