diff --git a/CHANGELOG.md b/CHANGELOG.md index b15f2b85c7..333b55cebf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/renderer/components/dialogs/ViewProfile.tsx b/src/renderer/components/dialogs/ViewProfile.tsx index fd7eeaf31c..1ca4bd15ce 100644 --- a/src/renderer/components/dialogs/ViewProfile.tsx +++ b/src/renderer/components/dialogs/ViewProfile.tsx @@ -28,6 +28,9 @@ import { BackendRemote, onDCEvent, Type } from '../../backend-com' 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() @@ -133,6 +136,10 @@ export function ViewProfileInner({ null ) const [selfChatAvatar, setSelfChatAvatar] = useState(null) + const [verifier, setVerifier] = useState void + }>(null) const isDeviceChat = contact.id === C.DC_CONTACT_ID_DEVICE const isSelfChat = contact.id === C.DC_CONTACT_ID_SELF @@ -166,6 +173,38 @@ export function ViewProfileInner({ } }, [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]) + const CHATLISTITEM_CHAT_HEIGHT = Number(useThemeCssVar('--SPECIAL-chatlist-item-chat-height')) || 64 @@ -211,22 +250,13 @@ export function ViewProfileInner({ {!isSelfChat && (
- {contact.isVerified && !contact.verifierAddr && ( -
- - {tx('verified')} -
- )} - {contact.isVerified && contact.verifierAddr && ( + {contact.isVerified && verifier && (
- contact.verifierId && - openViewProfileDialog(screenContext, contact.verifierId) - } + className={verifier.action && 'clickable'} + onClick={verifier.action} > - {tx('verified_by', contact.verifierAddr)} + {verifier.label}
)} {contact.lastSeen !== 0 && (