new release #190

Merged
b merged 68 commits from staging into main 2024-09-06 18:59:34 +00:00
3 changed files with 100 additions and 88 deletions
Showing only changes of commit 9dc160e89c - Show all commits

View File

@ -23,7 +23,7 @@ interface PdfMarkingProps {
meta: Meta | null meta: Meta | null
otherUserMarks: Mark[] otherUserMarks: Mark[]
setCurrentUserMarks: (currentUserMarks: CurrentUserMark[]) => void setCurrentUserMarks: (currentUserMarks: CurrentUserMark[]) => void
setIsReadyToSign: (isReadyToSign: boolean) => void setIsMarksCompleted: (isMarksCompleted: boolean) => void
setUpdatedMarks: (markToUpdate: Mark) => void setUpdatedMarks: (markToUpdate: Mark) => void
} }
@ -37,7 +37,7 @@ const PdfMarking = (props: PdfMarkingProps) => {
const { const {
files, files,
currentUserMarks, currentUserMarks,
setIsReadyToSign, setIsMarksCompleted,
setCurrentUserMarks, setCurrentUserMarks,
setUpdatedMarks, setUpdatedMarks,
handleDownload, handleDownload,
@ -101,7 +101,7 @@ const PdfMarking = (props: PdfMarkingProps) => {
) )
setCurrentUserMarks(updatedCurrentUserMarks) setCurrentUserMarks(updatedCurrentUserMarks)
setSelectedMark(null) setSelectedMark(null)
setIsReadyToSign(true) setIsMarksCompleted(true)
setUpdatedMarks(updatedMark.mark) setUpdatedMarks(updatedMark.mark)
} }

View File

@ -39,7 +39,7 @@ import { Container } from '../../components/Container'
import { DisplayMeta } from './internal/displayMeta' import { DisplayMeta } from './internal/displayMeta'
import styles from './style.module.scss' import styles from './style.module.scss'
import { CurrentUserMark, Mark } from '../../types/mark.ts' import { CurrentUserMark, Mark } from '../../types/mark.ts'
import { getLastSignersSig } from '../../utils/sign.ts' import { getLastSignersSig, isFullySigned } from '../../utils/sign.ts'
import { import {
filterMarksByPubkey, filterMarksByPubkey,
getCurrentUserMarks, getCurrentUserMarks,
@ -112,13 +112,13 @@ export const SignPage = () => {
const [currentUserMarks, setCurrentUserMarks] = useState<CurrentUserMark[]>( const [currentUserMarks, setCurrentUserMarks] = useState<CurrentUserMark[]>(
[] []
) )
const [isReadyToSign, setIsReadyToSign] = useState(false) const [isMarksCompleted, setIsMarksCompleted] = useState(false)
const [otherUserMarks, setOtherUserMarks] = useState<Mark[]>([]) const [otherUserMarks, setOtherUserMarks] = useState<Mark[]>([])
useEffect(() => { useEffect(() => {
if (signers.length > 0) { if (signers.length > 0) {
// check if all signers have signed then its fully signed // check if all signers have signed then its fully signed
if (signers.every((signer) => signedBy.includes(signer))) { if (isFullySigned(signers, signedBy)) {
setSignedStatus(SignedStatus.Fully_Signed) setSignedStatus(SignedStatus.Fully_Signed)
} else { } else {
for (const signer of signers) { for (const signer of signers) {
@ -216,7 +216,7 @@ export const SignPage = () => {
const otherUserMarks = findOtherUserMarks(signedMarks, usersPubkey!) const otherUserMarks = findOtherUserMarks(signedMarks, usersPubkey!)
setOtherUserMarks(otherUserMarks) setOtherUserMarks(otherUserMarks)
setCurrentUserMarks(currentUserMarks) setCurrentUserMarks(currentUserMarks)
setIsReadyToSign(isCurrentUserMarksComplete(currentUserMarks)) setIsMarksCompleted(isCurrentUserMarksComplete(currentUserMarks))
} }
setSignedBy(Object.keys(meta.docSignatures) as `npub1${string}`[]) setSignedBy(Object.keys(meta.docSignatures) as `npub1${string}`[])
@ -883,7 +883,21 @@ export const SignPage = () => {
return <LoadingSpinner desc={loadingSpinnerDesc} /> return <LoadingSpinner desc={loadingSpinnerDesc} />
} }
if (isReadyToSign) { if (!isMarksCompleted && signedStatus === SignedStatus.User_Is_Next_Signer) {
return (
<PdfMarking
files={getCurrentUserFiles(files, currentFileHashes, creatorFileHashes)}
currentUserMarks={currentUserMarks}
setIsMarksCompleted={setIsMarksCompleted}
setCurrentUserMarks={setCurrentUserMarks}
setUpdatedMarks={setUpdatedMarks}
handleDownload={handleDownload}
otherUserMarks={otherUserMarks}
meta={meta}
/>
)
}
return ( return (
<> <>
<Container className={styles.container}> <Container className={styles.container}>
@ -955,18 +969,4 @@ export const SignPage = () => {
</Container> </Container>
</> </>
) )
}
return (
<PdfMarking
files={getCurrentUserFiles(files, currentFileHashes, creatorFileHashes)}
currentUserMarks={currentUserMarks}
setIsReadyToSign={setIsReadyToSign}
setCurrentUserMarks={setCurrentUserMarks}
setUpdatedMarks={setUpdatedMarks}
handleDownload={handleDownload}
otherUserMarks={otherUserMarks}
meta={meta}
/>
)
} }

View File

@ -31,4 +31,16 @@ const getLastSignersSig = (
} }
} }
export { getLastSignersSig } /**
* Checks if all signers have signed the sigit
* @param signers - an array of npubs of all signers from the Sigit
* @param signedBy - an array of npubs that have signed it already
*/
const isFullySigned = (
signers: `npub1${string}`[],
signedBy: `npub1${string}`[]
): boolean => {
return signers.every((signer) => signedBy.includes(signer))
}
export { getLastSignersSig, isFullySigned }