more chat fixes

This commit is contained in:
Martti Malmi 2023-09-12 13:58:41 +03:00
parent 8fbde57db0
commit b97db6ab58
2 changed files with 11 additions and 3 deletions

View File

@ -10,7 +10,7 @@ import Show from '../helpers/Show';
import ProxyImg from '../ProxyImg.tsx'; import ProxyImg from '../ProxyImg.tsx';
type Props = { type Props = {
str: unknown; str: string;
hidePicture?: boolean; hidePicture?: boolean;
showTooltip?: boolean; showTooltip?: boolean;
activity?: string; activity?: string;
@ -23,7 +23,10 @@ const MyAvatar: React.FC<Props> = (props) => {
const [avatar, setAvatar] = useState<string | null>(null); const [avatar, setAvatar] = useState<string | null>(null);
const [hasError, setHasError] = useState<boolean>(false); const [hasError, setHasError] = useState<boolean>(false);
const hex = React.useMemo(() => Key.toNostrHexAddress(props.str as string), [props.str]); const hex = React.useMemo(
() => Key.toNostrHexAddress(props.str as string) || props.str,
[props.str],
);
const { picture, name } = useProfile(hex || ''); const { picture, name } = useProfile(hex || '');

View File

@ -242,7 +242,12 @@ export default {
try { try {
const hex = new Hex(address); const hex = new Hex(address);
return hex.toBech32(prefix); const bech32 = hex.toBech32(prefix);
if (bech32.length < 60) {
// not a nostr key
return null;
}
return bech32;
} catch (e) { } catch (e) {
// not a valid hex // not a valid hex
console.error(address, e); console.error(address, e);