fix warnings

This commit is contained in:
Bekbolsun 2024-02-14 14:45:36 +06:00
parent 1a9dc0da82
commit 8b349c0350
5 changed files with 20 additions and 27 deletions

View File

@ -5,8 +5,6 @@ import { useAppDispatch } from './store/hooks/redux'
import { setApps, setKeys, setPending, setPerms } from './store/reducers/content.slice'
import AppRoutes from './routes/AppRoutes'
import { fetchProfile, ndk } from './modules/nostr'
import { useModalSearchParams } from './hooks/useModalSearchParams'
import { MODAL_PARAMS_KEYS } from './types/modal'
import { ModalInitial } from './components/Modal/ModalInitial/ModalInitial'
import { ModalImportKeys } from './components/Modal/ModalImportKeys/ModalImportKeys'
import { ModalSignUp } from './components/Modal/ModalSignUp/ModalSignUp'
@ -14,7 +12,6 @@ import { ModalLogin } from './components/Modal/ModalLogin/ModalLogin'
function App() {
const [render, setRender] = useState(0)
const { handleOpen } = useModalSearchParams()
const dispatch = useAppDispatch()
const [isConnected, setIsConnected] = useState(false)

View File

@ -69,12 +69,13 @@ export const ModalImportKeys = () => {
}
try {
const { type, data } = nip19.decode(debouncedNsec)
const ok = type === 'nsec';
const ok = type === 'nsec'
setIsBadNsec(!ok)
if (ok) {
const npub = nip19.npubEncode(
// @ts-ignore
getPublicKey(data))
getPublicKey(data)
)
setIsTakenByNsec(!!nameNpub && nameNpub === npub)
} else {
setIsTakenByNsec(false)
@ -84,7 +85,8 @@ export const ModalImportKeys = () => {
setIsTakenByNsec(false)
return
}
}, [debouncedNsec])
// eslint-disable-next-line
}, [debouncedNsec])
useEffect(() => {
checkNsecUsername()
@ -106,8 +108,8 @@ export const ModalImportKeys = () => {
if (isLoading) return undefined
try {
const { nsec, username } = values
if (!nsec || !username) throw new Error("Enter username and nsec")
if (nameNpub && !isTakenByNsec) throw new Error("Name taken")
if (!nsec || !username) throw new Error('Enter username and nsec')
if (nameNpub && !isTakenByNsec) throw new Error('Name taken')
setIsLoading(true)
const k: any = await swicCall('importKey', username, nsec)
notify('Key imported!', 'success')
@ -186,9 +188,7 @@ export const ModalImportKeys = () => {
helperTextProps={{
sx: {
'&.helper_text': {
color: isBadNsec
? theme.palette.error.main
: theme.palette.textSecondaryDecorate.main,
color: isBadNsec ? theme.palette.error.main : theme.palette.textSecondaryDecorate.main,
},
},
}}

View File

@ -1,5 +1,4 @@
import { useModalSearchParams } from '@/hooks/useModalSearchParams'
import { Button } from '@/shared/Button/Button'
import { Modal } from '@/shared/Modal/Modal'
import { MODAL_PARAMS_KEYS } from '@/types/modal'
import { Box, CircularProgress, Stack, Typography } from '@mui/material'
@ -116,15 +115,7 @@ export const ModalSettings: FC<ModalSettingsProps> = ({ isSynced }) => {
{...inputProps}
onChange={handlePasswordChange}
value={enteredPassword}
// helperText={isPasswordInvalid ? 'Invalid password' : ''}
placeholder="Enter a password"
// helperTextProps={{
// sx: {
// '&.helper_text': {
// color: 'red',
// },
// },
// }}
disabled={!isChecked}
/>
{isPasswordInvalid ? (
@ -153,7 +144,6 @@ export const ModalSettings: FC<ModalSettingsProps> = ({ isSynced }) => {
Sync {isLoading && <CircularProgress sx={{ marginLeft: '0.5rem' }} size={'1rem'} />}
</StyledButton>
</StyledSettingContainer>
{/* <Button onClick={onClose}>Done</Button> */}
</Stack>
</Modal>
)

View File

@ -70,12 +70,19 @@ export const useTriggerConfirmModal = (npub: string, pending: DbPending[], perms
search: {
appNpub: req.appNpub,
reqId: req.id,
popup: isPopup ? 'true' : ''
popup: isPopup ? 'true' : '',
},
})
break
}
}, [connectPendings, filteredPendingReqs.length, handleOpen, isConfirmEventModalOpened, isConfirmConnectModalOpened])
}, [
connectPendings,
filteredPendingReqs.length,
handleOpen,
isConfirmEventModalOpened,
isConfirmConnectModalOpened,
isPopup,
])
const handleOpenConfirmEventModal = useCallback(() => {
if (!filteredPendingReqs.length || connectPendings.length) return undefined
@ -91,12 +98,12 @@ export const useTriggerConfirmModal = (npub: string, pending: DbPending[], perms
handleOpen(MODAL_PARAMS_KEYS.CONFIRM_EVENT, {
search: {
appNpub,
popup: isPopup ? 'true' : ''
popup: isPopup ? 'true' : '',
},
})
break
}
}, [connectPendings.length, filteredPendingReqs.length, handleOpen, prepareEventPendings])
}, [connectPendings.length, filteredPendingReqs.length, handleOpen, prepareEventPendings, isPopup])
useEffect(() => {
handleOpenConfirmEventModal()

View File

@ -110,8 +110,7 @@ export const getReferrerAppUrl = () => {
if (!window.document.referrer) return ''
try {
const u = new URL(window.document.referrer.toLocaleLowerCase())
if (u.hostname != DOMAIN && !u.hostname.endsWith("."+DOMAIN))
return u.origin
if (u.hostname !== DOMAIN && !u.hostname.endsWith('.' + DOMAIN)) return u.origin
} catch {}
return ''
}