mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-10-01 17:31:13 +00:00
Fix bug for profile qr code when ln is missing
This commit is contained in:
parent
8ac6fdf624
commit
b34dbfaac3
@ -1,24 +1,15 @@
|
|||||||
import { useIntl } from '@cookbook/solid-intl';
|
import { useIntl } from '@cookbook/solid-intl';
|
||||||
import { Tabs } from '@kobalte/core';
|
import { Tabs } from '@kobalte/core';
|
||||||
import { Component, createEffect, createSignal, For, Show } from 'solid-js';
|
import { Component, For, Show } from 'solid-js';
|
||||||
import { defaultZap, defaultZapOptions } from '../../constants';
|
|
||||||
import { useAccountContext } from '../../contexts/AccountContext';
|
|
||||||
import { useSettingsContext } from '../../contexts/SettingsContext';
|
|
||||||
import { hookForDev } from '../../lib/devTools';
|
import { hookForDev } from '../../lib/devTools';
|
||||||
import { hexToNpub } from '../../lib/keys';
|
import { hexToNpub } from '../../lib/keys';
|
||||||
import { truncateNumber } from '../../lib/notifications';
|
import { authorName, nip05Verification, truncateNpub } from '../../stores/profile';
|
||||||
import { zapNote, zapProfile } from '../../lib/zap';
|
import { profile as tProfile } from '../../translations';
|
||||||
import { authorName, nip05Verification, truncateNpub, userName } from '../../stores/profile';
|
import { PrimalUser } from '../../types/primal';
|
||||||
import { toastZapFail, zapCustomOption, actions as tActions, placeholders as tPlaceholders, zapCustomAmount } from '../../translations';
|
|
||||||
import { PrimalNote, PrimalUser, ZapOption } from '../../types/primal';
|
|
||||||
import { debounce } from '../../utils';
|
|
||||||
import Avatar from '../Avatar/Avatar';
|
import Avatar from '../Avatar/Avatar';
|
||||||
import ButtonCopy from '../Buttons/ButtonCopy';
|
import ButtonCopy from '../Buttons/ButtonCopy';
|
||||||
import ButtonPrimary from '../Buttons/ButtonPrimary';
|
|
||||||
import Modal from '../Modal/Modal';
|
import Modal from '../Modal/Modal';
|
||||||
import QrCode from '../QrCode/QrCode';
|
import QrCode from '../QrCode/QrCode';
|
||||||
import TextInput from '../TextInput/TextInput';
|
|
||||||
import { useToastContext } from '../Toaster/Toaster';
|
|
||||||
import VerificationCheck from '../VerificationCheck/VerificationCheck';
|
import VerificationCheck from '../VerificationCheck/VerificationCheck';
|
||||||
|
|
||||||
import styles from './ProfileQrCodeModal.module.scss';
|
import styles from './ProfileQrCodeModal.module.scss';
|
||||||
@ -30,18 +21,22 @@ const ProfileQrCodeModal: Component<{
|
|||||||
onClose?: () => void,
|
onClose?: () => void,
|
||||||
}> = (props) => {
|
}> = (props) => {
|
||||||
|
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
const profileData = () => Object.entries({
|
const profileData = () => Object.entries({
|
||||||
pubkey: {
|
pubkey: {
|
||||||
title: 'Public key',
|
title: intl.formatMessage(tProfile.qrModal.pubkey),
|
||||||
data: `nostr:${props.profile.npub || hexToNpub(props.profile.pubkey)}`,
|
data: `nostr:${props.profile.npub || hexToNpub(props.profile.pubkey)}`,
|
||||||
dataLabel: props.profile.npub || hexToNpub(props.profile.pubkey),
|
dataLabel: props.profile.npub || hexToNpub(props.profile.pubkey) || '',
|
||||||
type: 'nostr',
|
type: 'nostr',
|
||||||
|
test: props.profile.npub || hexToNpub(props.profile.pubkey),
|
||||||
},
|
},
|
||||||
lnAddress: {
|
lnAddress: {
|
||||||
title: 'Lightning address',
|
title: intl.formatMessage(tProfile.qrModal.ln),
|
||||||
data: `lightning:${props.profile.lud16 || props.profile.lud06}`,
|
data: `lightning:${props.profile.lud16 || props.profile.lud06}`,
|
||||||
dataLabel: props.profile.lud16 || props.profile.lud06,
|
dataLabel: props.profile.lud16 || props.profile.lud06 || '',
|
||||||
type: 'lightning',
|
type: 'lightning',
|
||||||
|
test: props.profile.lud16 || props.profile.lud06,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -82,7 +77,7 @@ const ProfileQrCodeModal: Component<{
|
|||||||
<Tabs.List class={styles.tabs}>
|
<Tabs.List class={styles.tabs}>
|
||||||
<For each={profileData()}>
|
<For each={profileData()}>
|
||||||
{([key, info]) =>
|
{([key, info]) =>
|
||||||
<Show when={info.data}>
|
<Show when={info.test}>
|
||||||
<Tabs.Trigger class={styles.tab} value={key} >
|
<Tabs.Trigger class={styles.tab} value={key} >
|
||||||
{info.title}
|
{info.title}
|
||||||
</Tabs.Trigger>
|
</Tabs.Trigger>
|
||||||
@ -95,7 +90,7 @@ const ProfileQrCodeModal: Component<{
|
|||||||
|
|
||||||
<For each={profileData()}>
|
<For each={profileData()}>
|
||||||
{([key, info]) =>
|
{([key, info]) =>
|
||||||
<Show when={info.data}>
|
<Show when={info.test}>
|
||||||
<Tabs.Content class={styles.tabContent} value={key}>
|
<Tabs.Content class={styles.tabContent} value={key}>
|
||||||
<QrCode data={info.data} type={info.type} />
|
<QrCode data={info.data} type={info.type} />
|
||||||
</Tabs.Content>
|
</Tabs.Content>
|
||||||
@ -109,7 +104,7 @@ const ProfileQrCodeModal: Component<{
|
|||||||
|
|
||||||
<For each={profileData()}>
|
<For each={profileData()}>
|
||||||
{([key, info]) =>
|
{([key, info]) =>
|
||||||
<Show when={info.data}>
|
<Show when={info.test}>
|
||||||
<div class={styles.keyEntry}>
|
<div class={styles.keyEntry}>
|
||||||
<div class={styles.label}>
|
<div class={styles.label}>
|
||||||
{info.title}:
|
{info.title}:
|
||||||
|
@ -1234,6 +1234,19 @@ export const profile = {
|
|||||||
defaultMessage: '{name} is on no relays',
|
defaultMessage: '{name} is on no relays',
|
||||||
description: 'Label indicating that the profile has no relays',
|
description: 'Label indicating that the profile has no relays',
|
||||||
},
|
},
|
||||||
|
qrModal: {
|
||||||
|
pubkey: {
|
||||||
|
id: 'profile.qrModal.pubkey',
|
||||||
|
defaultMessage: 'Public key',
|
||||||
|
description: 'Public key tab title in profile qr code modal',
|
||||||
|
},
|
||||||
|
ln: {
|
||||||
|
id: 'profile.qrModal.ln',
|
||||||
|
defaultMessage: 'Lightning address',
|
||||||
|
description: 'Lightning address tab title in profile qr code modal',
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const search = {
|
export const search = {
|
||||||
|
Loading…
Reference in New Issue
Block a user