-
-
Couldn't load subscription status.
- Fork 135
fix(Mention): Maintain mention after nym change #2591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { USER } from '@/fragments/users' | ||
| import { USER, USER_BY_MENTION } from '@/fragments/users' | ||
| import errorStyles from '@/styles/error.module.css' | ||
| import { useLazyQuery } from '@apollo/client' | ||
| import { useLazyQuery, useQuery } from '@apollo/client' | ||
| import classNames from 'classnames' | ||
| import Link from 'next/link' | ||
| import HoverablePopover from './hoverable-popover' | ||
|
|
@@ -22,7 +22,16 @@ function StackingSince ({ since }) { | |
| ) | ||
| } | ||
|
|
||
| export default function UserPopover ({ name, children }) { | ||
| export default function UserPopover ({ name, itemId, children }) { | ||
| const { data: mentionData, loading: mentionLoading } = useQuery( | ||
| USER_BY_MENTION, | ||
| { | ||
| variables: { name, itemId }, | ||
| skip: !itemId, | ||
| fetchPolicy: 'cache-first' | ||
| } | ||
| ) | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const [getUser, { loading, data }] = useLazyQuery( | ||
| USER, | ||
| { | ||
|
|
@@ -31,17 +40,25 @@ export default function UserPopover ({ name, children }) { | |
| } | ||
| ) | ||
|
|
||
| const resolvedUser = mentionData?.userByMention | ||
| const popoverUser = resolvedUser || data?.user | ||
| const isLoading = loading || (itemId && mentionLoading && !resolvedUser) | ||
| const trigger = | ||
| typeof children === 'function' | ||
| ? children({ user: popoverUser }) | ||
| : children | ||
|
|
||
| return ( | ||
| <HoverablePopover | ||
| onShow={getUser} | ||
| trigger={children} | ||
| body={!data || loading | ||
| trigger={trigger} | ||
| body={isLoading | ||
| ? <UserSkeleton /> | ||
| : !data.user | ||
| : !popoverUser | ||
| ? <h1 className={classNames(errorStyles.status, errorStyles.describe)}>USER NOT FOUND</h1> | ||
| : ( | ||
| <UserBase user={data.user} className='mb-0 pb-0'> | ||
| <StackingSince since={data.user.since} /> | ||
| <UserBase user={popoverUser} className='mb-0 pb-0'> | ||
| <StackingSince since={popoverUser.since} /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: UserPopover Loading and Display Logic ErrorsThe |
||
| </UserBase> | ||
| )} | ||
| /> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.