Skip to content
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

fix "Verified by" is shown weirdly for contacts that were verified directly #3433

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- add description for enableChatAuditLog setting
- fix: import key from file instead of folder, fixes #1863
- fix webxdc title not updated in document title changes #3412
- fix "Verified by" is shown weirdly for contacts that were verified directly #3421

<a id="1_40_4"></a>

Expand Down
56 changes: 43 additions & 13 deletions src/renderer/components/dialogs/ViewProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import { selectedAccountId } from '../../ScreenController'
import moment from 'moment'
import { InlineVerifiedIcon } from '../VerifiedIcon'
import { getLogger } from '../../../shared/logger'

const log = getLogger('renderer/dialogs/ViewProfile')

function LastSeen({ timestamp }: { timestamp: number }) {
const tx = useTranslationFunction()
Expand Down Expand Up @@ -133,6 +136,10 @@
null
)
const [selfChatAvatar, setSelfChatAvatar] = useState<string | null>(null)
const [verifier, setVerifier] = useState<null | {
label: string
action?: () => void
}>(null)
const isDeviceChat = contact.id === C.DC_CONTACT_ID_DEVICE
const isSelfChat = contact.id === C.DC_CONTACT_ID_SELF

Expand Down Expand Up @@ -166,6 +173,38 @@
}
}, [accountId, isSelfChat])

useEffect(() => {
;(async () => {
if (contact.verifierId === null) {
setVerifier({ label: tx('verified') })
} else if (contact.verifierId === C.DC_CONTACT_ID_SELF) {
setVerifier({ label: tx('verified_by_you') })
} else {
setVerifier(null) // make sure it rather shows nothing than wrong values
const verifierContactId = contact.verifierId
try {
const { address } = await BackendRemote.rpc.getContact(
accountId,
verifierContactId
)
setVerifier({
label: tx('verified_by', address),
action: () =>
openViewProfileDialog(screenContext, verifierContactId),
})
} catch (error) {
log.error('failed to load verifier contact', error)
setVerifier({
label:
'verified by: failed to load verifier contact, please report this issue',
action: () =>
openViewProfileDialog(screenContext, verifierContactId),
})
}
}
})()
}, [accountId, contact.id, contact.verifierId])

Check warning on line 206 in src/renderer/components/dialogs/ViewProfile.tsx

View workflow job for this annotation

GitHub Actions / Code Validation

React Hook useEffect has missing dependencies: 'screenContext' and 'tx'. Either include them or remove the dependency array

const CHATLISTITEM_CHAT_HEIGHT =
Number(useThemeCssVar('--SPECIAL-chatlist-item-chat-height')) || 64

Expand Down Expand Up @@ -211,22 +250,13 @@
</div>
{!isSelfChat && (
<div className='contact-attributes'>
{contact.isVerified && !contact.verifierAddr && (
<div>
<InlineVerifiedIcon />
{tx('verified')}
</div>
)}
{contact.isVerified && contact.verifierAddr && (
{contact.isVerified && verifier && (
<div
className='clickable'
onClick={() =>
contact.verifierId &&
openViewProfileDialog(screenContext, contact.verifierId)
}
className={verifier.action && 'clickable'}
onClick={verifier.action}
>
<InlineVerifiedIcon />
{tx('verified_by', contact.verifierAddr)}
{verifier.label}
</div>
)}
{contact.lastSeen !== 0 && (
Expand Down
Loading