Use click on nym to switch

This commit is contained in:
ekzyis 2023-12-05 05:11:14 +01:00
parent 47dc05d285
commit c1e7b93688
2 changed files with 8 additions and 5 deletions

View File

@ -79,7 +79,9 @@ const AccountListRow = ({ account, ...props }) => {
}
)
const onClick = async () => {
const onClick = async (e) => {
// prevent navigation
e.preventDefault()
document.cookie = `multi_auth.user-id=${anonRow ? 'anonymous' : account.id}; Path=/; Secure`
if (anonRow) {
// order is important to prevent flashes of no session
@ -94,8 +96,7 @@ const AccountListRow = ({ account, ...props }) => {
// can't show hat since we don't have access to the streak from the data available in the cookies
return (
<div className='d-flex flex-row'>
<UserListRow user={{ ...account, photoId, name }} className='d-flex align-items-center me-2' {...props} />
<div className='me-2' style={{ cursor: 'pointer' }} onClick={onClick}>switch</div>
<UserListRow user={{ ...account, photoId, name }} className='d-flex align-items-center me-2' {...props} onNymClick={onClick} />
{selected && <div className='text-muted fst-italic text-muted'>selected</div>}
</div>
)

View File

@ -36,7 +36,7 @@ function seperate (arr, seperator) {
return arr.flatMap((x, i) => i < arr.length - 1 ? [x, seperator] : [x])
}
export const UserListRow = ({ user, stats, className, showHat = true }) => {
export const UserListRow = ({ user, stats, className, onNymClick, showHat = true }) => {
return (
<div className={`${styles.item} mb-2`} key={user.name}>
<Link href={`/${user.name}`}>
@ -46,7 +46,9 @@ export const UserListRow = ({ user, stats, className, showHat = true }) => {
/>
</Link>
<div className={`${styles.hunk} ${className}`}>
<Link href={`/${user.name}`} className={`${styles.title} d-inline-flex align-items-center text-reset`}>
<Link
href={`/${user.name}`} className={`${styles.title} d-inline-flex align-items-center text-reset`} onClick={onNymClick}
>
@{user.name}{showHat && <Hat className='ms-1 fill-grey' height={14} width={14} user={user} />}
</Link>
{stats && (