Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const DisconnectProfileDialog = ({
variant="contained"
onClick={() => {
onDisconnect(profileIdentifier)
setCurrentStep(steps.selection)
onClose()
}}>
{t.confirm()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const PersonaRowCard = memo(() => {
connectPersona,
disconnectPersona,
renamePersona,
operateBound,
deleteBound,
definedSocialNetworks,
verification,
} = PersonaContext.useContainer()
Expand All @@ -83,7 +83,7 @@ export const PersonaRowCard = memo(() => {
profiles={currentPersona.linkedProfiles}
onConnect={connectPersona}
onDisconnect={disconnectPersona}
onDeleteBound={operateBound}
onDeleteBound={deleteBound}
onRename={renamePersona}
definedSocialNetworks={definedSocialNetworks}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Box, Button, Link, Stack, Typography } from '@mui/material'
import { getMaskColor, MaskColorVar, makeStyles } from '@masknet/theme'
import { useDashboardI18N } from '../../../../locales'
import { DisconnectProfileDialog } from '../DisconnectProfileDialog'
import type { NextIDPersonaBindings, PersonaIdentifier, ProfileIdentifier } from '@masknet/shared-base'
import type { NextIDPersonaBindings, PersonaIdentifier, ProfileIdentifier, BindingProof } from '@masknet/shared-base'
import { SOCIAL_MEDIA_ICON_MAPPING } from '@masknet/shared'
import { PersonaContext } from '../../hooks/usePersonaContext'
import { NextIdPersonaWarningIcon, NextIdPersonaVerifiedIcon } from '@masknet/icons'
Expand Down Expand Up @@ -101,7 +101,7 @@ export const ConnectedPersonaLine = memo<ConnectedPersonaLineProps>(
const handleUserIdClick = async (network: string, userId: string) => {
await openProfilePage(network, userId)
}
const handleProofIconClick = async (e: MouseEvent, proof: any, profile: any) => {
const handleProofIconClick = (e: MouseEvent, proof: BindingProof | undefined) => {
e.stopPropagation()
if (!proof || !proof.is_valid) {
onConnect()
Expand All @@ -112,24 +112,21 @@ export const ConnectedPersonaLine = memo<ConnectedPersonaLineProps>(
const isProved = verification?.proofs.find((x) => {
return x.platform === 'twitter' && x.identity === profile.userId.toLowerCase()
})

if (!isProved || !onDeleteBound) {
onDisconnect(profile)
} else {
if (isProved && onDeleteBound) {
onDeleteBound(profile)
return
}
onDisconnect(profile)
}
const userIdBox = (profile: any) => {
const userIdBox = (profile: ProfileIdentifier) => {
const proofSupport = ['twitter.com'].includes(profile.network)
const proof = verification?.proofs.find((x) => {
return x.platform === 'twitter' && x.identity === profile.userId.toLowerCase()
})
return (
<div className={classes.userIdBox}>
<div>@{profile.userId}</div>
<div
className={classes.proofIconBox}
onClick={(e: MouseEvent) => handleProofIconClick(e, proof, profile)}>
<div className={classes.proofIconBox} onClick={(e: MouseEvent) => handleProofIconClick(e, proof)}>
{!proofSupport ? null : proof?.is_valid ? (
<NextIdPersonaVerifiedIcon />
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { bindProof, createPersonaPayload } from '@masknet/web3-providers'
import { useAsyncFn } from 'react-use'
import { Services } from '../../../API'

export function useOperateBound() {
export function useDeleteBound() {
return useAsyncFn(async (identifier: ECKeyIdentifier, profile, network, action) => {
const persona_ = await Services.Identity.queryPersona(identifier)
const username = profile.userId.toLowerCase()
Expand All @@ -21,6 +21,6 @@ export function useOperateBound() {
await bindProof(persona_.publicHexKey, action, platform, username, {
signature: signature,
})
await Services.Identity.detachProfile(profile)
Services.Identity.detachProfile(profile)
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useCreatePersona } from './useCreatePersona'
import { queryExistedBindingByPersona } from '@masknet/web3-providers'
import { useAsync, useAsyncRetry } from 'react-use'
import type { ECKeyIdentifier } from '@masknet/shared-base'
import { useOperateBound } from './useOperateBindingProof'
import { useDeleteBound } from './useOperateBindingProof'

function usePersonaContext() {
const currentPersonaIdentifier = useCurrentPersonaIdentifier()
Expand All @@ -28,7 +28,7 @@ function usePersonaContext() {
const [, openProfilePage] = useOpenProfilePage()
const [, disconnectPersona] = useDisconnectSocialNetwork()
const [, createPersona] = useCreatePersona()
const [, operateBound] = useOperateBound()
const [, deleteBound] = useDeleteBound()
const renamePersona = Services.Identity.renamePersona
const changeCurrentPersona = useCallback(Services.Settings.setCurrentPersonaIdentifier, [])

Expand All @@ -38,7 +38,7 @@ function usePersonaContext() {
createPersona,
renamePersona,
changeCurrentPersona,
operateBound,
deleteBound,
currentPersona,
definedSocialNetworks,
personas,
Expand Down
18 changes: 10 additions & 8 deletions packages/shared-base/src/NextID/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ export interface Binding {

export interface NextIDPersonaBindings {
persona: string
proofs: {
platform: NextIDPlatform
identity: string
created_at: string
invalid_reason: string
latest_checked_at: string
is_valid: boolean
}[]
proofs: BindingProof[]
}

export interface BindingProof {
platform: NextIDPlatform
identity: string
created_at: string
invalid_reason: string
latest_checked_at: string
is_valid: boolean
}

export interface NextIDBindings {
Expand Down