From dfdcb8419d5b3c8ca34c6f9590107ce120a53174 Mon Sep 17 00:00:00 2001 From: enes Date: Tue, 17 Sep 2024 17:21:30 +0200 Subject: [PATCH 1/2] fix(marks): add default signer --- src/components/DrawPDFFields/index.tsx | 113 ++++++++++++------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/src/components/DrawPDFFields/index.tsx b/src/components/DrawPDFFields/index.tsx index 7c1227d..aa6b0e5 100644 --- a/src/components/DrawPDFFields/index.tsx +++ b/src/components/DrawPDFFields/index.tsx @@ -37,6 +37,8 @@ interface Props { export const DrawPDFFields = (props: Props) => { const { selectedFiles, selectedTool, onDrawFieldsChange, users } = props + const signers = users.filter((u) => u.role === UserRole.signer) + const defaultSignerNpub = signers.length ? hexToNpub(signers[0].pubkey) : '' const { to, from } = useScale() const [sigitFiles, setSigitFiles] = useState([]) @@ -115,7 +117,7 @@ export const DrawPDFFields = (props: Props) => { top: to(page.width, y), width: event.pointerType === 'mouse' ? 0 : DEFAULT_START_SIZE.width, height: event.pointerType === 'mouse' ? 0 : DEFAULT_START_SIZE.height, - counterpart: '', + counterpart: defaultSignerNpub, type: selectedTool.identifier } @@ -453,7 +455,9 @@ export const DrawPDFFields = (props: Props) => { Counterpart @@ -524,28 +523,28 @@ export const DrawPDFFields = (props: Props) => { ) } - const renderCounterpartValue = (value: string) => { - const user = users.find((u) => u.pubkey === npubToHex(value)) - if (user) { - let displayValue = truncate(value, { - length: 16 - }) - - const metadata = props.metadata[user.pubkey] + const renderCounterpartValue = (npub: string) => { + let displayValue = truncate(npub, { + length: 16 + }) + const signer = signers.find((u) => u.pubkey === npubToHex(npub)) + if (signer) { + const metadata = props.metadata[signer.pubkey] if (metadata) { displayValue = truncate( - metadata.name || metadata.display_name || metadata.username || value, + metadata.display_name || metadata.name || npub, { length: 16 } ) } + return ( <> { ) } - return value + return displayValue } if (parsingPdf) { From 39934f59c375d774f1fb4f7a97676304f5e9fd41 Mon Sep 17 00:00:00 2001 From: enes Date: Thu, 19 Sep 2024 11:46:34 +0200 Subject: [PATCH 2/2] fix: last signer as default next --- src/components/DrawPDFFields/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/DrawPDFFields/index.tsx b/src/components/DrawPDFFields/index.tsx index aa6b0e5..194291f 100644 --- a/src/components/DrawPDFFields/index.tsx +++ b/src/components/DrawPDFFields/index.tsx @@ -39,6 +39,7 @@ export const DrawPDFFields = (props: Props) => { const { selectedFiles, selectedTool, onDrawFieldsChange, users } = props const signers = users.filter((u) => u.role === UserRole.signer) const defaultSignerNpub = signers.length ? hexToNpub(signers[0].pubkey) : '' + const [lastSigner, setLastSigner] = useState(defaultSignerNpub) const { to, from } = useScale() const [sigitFiles, setSigitFiles] = useState([]) @@ -117,7 +118,7 @@ export const DrawPDFFields = (props: Props) => { top: to(page.width, y), width: event.pointerType === 'mouse' ? 0 : DEFAULT_START_SIZE.width, height: event.pointerType === 'mouse' ? 0 : DEFAULT_START_SIZE.height, - counterpart: defaultSignerNpub, + counterpart: lastSigner, type: selectedTool.identifier } @@ -456,10 +457,14 @@ export const DrawPDFFields = (props: Props) => { Counterpart