fix(chat): truncate CAIP-2 address when displaying in summary/header

This commit is contained in:
Ben Kremer 2022-10-28 15:29:21 +02:00
parent 2e15c447dc
commit 9f3aa00864
2 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import { demoAddressResolver } from '@/config/chatConstants'
import { truncate } from '@/utils/HelperUtil'
import { Card, Text } from '@nextui-org/react'
import Image from 'next/image'
import NextLink from 'next/link'
@ -40,7 +41,7 @@ export default function ChatSummaryCard({ peerAccount, topic, latestMessage }: I
<ChatAvatar />
<div style={{ flex: 1 }}>
<Text h5 css={{ marginLeft: '$9' }}>
{demoAddressResolver[peerAccount] ?? peerAccount}
{demoAddressResolver[peerAccount] ?? truncate(peerAccount, 24)}
</Text>
<Text h6 weight="normal" css={{ marginLeft: '$9' }}>
{latestMessage ?? ''}

View File

@ -9,6 +9,7 @@ import PageHeader from '@/components/PageHeader'
import { demoAddressResolver } from '@/config/chatConstants'
import SettingsStore from '@/store/SettingsStore'
import { chatClient } from '@/utils/WalletConnectUtil'
import { truncate } from '@/utils/HelperUtil'
const ChatContainer = styled('div', {
display: 'flex',
@ -65,7 +66,7 @@ export default function ChatPage() {
function getChatTitle() {
if (typeof query.peerAccount !== 'string') return ''
return demoAddressResolver[query.peerAccount] ?? query.peerAccount
return demoAddressResolver[query.peerAccount] ?? truncate(query.peerAccount, 24)
}
useEffect(() => {