Skip to content

Commit 4b5ce99

Browse files
committed
Fix avatar link not working on mobile
1 parent f8dff77 commit 4b5ce99

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

web/components/widgets/avatar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Router from 'next/router'
1+
import {useRouter} from 'next/router'
22
import clsx from 'clsx'
33
import {memo, MouseEvent, useEffect, useState} from 'react'
44
import {UserIcon, UsersIcon} from '@heroicons/react/solid'
@@ -17,6 +17,7 @@ export const Avatar = memo(
1717
}) => {
1818
const {username, noLink, size, className, preventDefault} = props
1919
const [avatarUrl, setAvatarUrl] = useState(props.avatarUrl)
20+
const router = useRouter()
2021
useEffect(() => setAvatarUrl(props.avatarUrl), [props.avatarUrl])
2122
const s =
2223
size == '2xs'
@@ -40,7 +41,7 @@ export const Avatar = memo(
4041
e.preventDefault()
4142
}
4243
e.stopPropagation()
43-
Router.push(`/${username}`)
44+
router.push(`/${username}`)
4445
}
4546
}
4647
const fallbackInitial = (username || 'U')[0]; // first character, not encoded string

web/pages/messages/index.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,20 @@ export const MessageChannelRow = (props: {
9696

9797
const isBanned = otherUsers?.length == 1 && otherUsers[0].isBannedFromPosting
9898
return (
99-
<Link
100-
className="hover:bg-canvas-0 rounded p-2 transition-colors"
101-
key={channelId}
102-
href={'/messages/' + channelId}
103-
>
104-
<Row className={'items-center gap-3 rounded-md'}>
105-
<MultipleOrSingleAvatars
106-
size="md"
107-
spacing={numOthers === 2 ? 0.3 : 0.15}
108-
startLeft={numOthers === 2 ? 2.2 : 1.2}
109-
avatars={otherUsers ?? []}
110-
className={numOthers > 1 ? '-ml-2' : ''}
111-
/>
112-
<Col className={'w-full'}>
99+
<Row className={'items-center gap-3 rounded-md'}>
100+
<MultipleOrSingleAvatars
101+
size="md"
102+
spacing={numOthers === 2 ? 0.3 : 0.15}
103+
startLeft={numOthers === 2 ? 2.2 : 1.2}
104+
avatars={otherUsers ?? []}
105+
className={numOthers > 1 ? '-ml-2' : ''}
106+
/>
107+
<Link
108+
className="hover:bg-canvas-0 rounded p-2 transition-colors w-full"
109+
key={channelId}
110+
href={'/messages/' + channelId}
111+
>
112+
<Col className={''}>
113113
<Row className={'items-center justify-between'}>
114114
<span className={'font-semibold'}>
115115
{otherUsers && (
@@ -150,7 +150,7 @@ export const MessageChannelRow = (props: {
150150
)}
151151
</Row>
152152
</Col>
153-
</Row>
154-
</Link>
153+
</Link>
154+
</Row>
155155
)
156156
}

0 commit comments

Comments
 (0)