Fix loading profile for username at KeyPage, fix nofity typo

This commit is contained in:
artur 2024-01-23 09:47:40 +03:00
parent 2115ce340d
commit a4739068ff
2 changed files with 9 additions and 16 deletions

View File

@ -112,11 +112,8 @@ export const ModalConfirmEvent: FC<ModalConfirmEventProps> = ({
async function confirmPending() {
selectedPendingRequests.forEach((req) => {
call(async () => {
if (selectedActionType === ACTION_TYPE.ONCE) {
await swicCall('confirm', req.id, true, false)
} else {
await swicCall('confirm', req.id, true, true)
}
const remember = selectedActionType !== ACTION_TYPE.ONCE
await swicCall('confirm', req.id, true, remember)
console.log('confirmed', req.id, selectedActionType)
})
})

View File

@ -49,10 +49,10 @@ const KeyPage = () => {
MODAL_PARAMS_KEYS.CONFIRM_EVENT,
)
const nofity = useEnqueueSnackbar()
const notify = useEnqueueSnackbar()
const [profile, setProfile] = useState<MetaEvent | null>(null)
const userName = profile?.info?.name || getShortenNpub(npub)
const userName = profile?.info?.name || profile?.info?.display_name || getShortenNpub(npub)
const userNameWithPrefix = userName + '@nsec.app'
const [showWarning, setShowWarning] = useState(false)
@ -91,17 +91,13 @@ const KeyPage = () => {
const load = useCallback(async () => {
try {
const npubToken = npub.includes('#') ? npub.split('#')[0] : npub
const { type, data: pubkey } = nip19.decode(npubToken)
if (type !== 'npub') return undefined
const response = await fetchProfile(pubkey)
const response = await fetchProfile(npub)
setProfile(response as any)
} catch (e) {
return undefined
}
// eslint-disable-next-line
}, [])
}, [npub])
useEffect(() => {
load()
@ -137,12 +133,12 @@ const KeyPage = () => {
setIsLoading(true)
await askNotificationPermission()
const r = await swicCall('enablePush')
if (!r) return nofity(`Failed to enable push subscription`, 'error')
nofity('Enabled!', 'success')
if (!r) return notify(`Failed to enable push subscription`, 'error')
notify('Enabled!', 'success')
checkBackgroundSigning()
setIsLoading(false)
} catch (e) {
nofity(`Failed to enable push subscription`, 'error')
notify(`Failed to enable push subscription`, 'error')
setIsLoading(false)
}
}