@@ -199,10 +199,14 @@ import { SigningRequirementValidator } from '../../../services/SigningRequiremen
199199import { SignFlowHandler } from ' ../../../services/SignFlowHandler'
200200import {
201201 normalizeDocumentForVisibleElements ,
202- normalizeFileForVisibleElements ,
203202} from ' ../../../services/signingDocumentAdapter'
204203import { FILE_STATUS } from ' ../../../constants.js'
205- import { getFileSigners , getVisibleElementsFromDocument , idsMatch , isCurrentUserSigner } from ' ../../../services/visibleElementsService'
204+ import {
205+ getCurrentUserSignRequestIds ,
206+ hasVisibleElementsForCurrentUser ,
207+ getVisibleElementsFromDocument ,
208+ idsMatch ,
209+ } from ' ../../../services/visibleElementsService'
206210
207211type OpenApiAccountMe = operations [' account-me' ][' responses' ][200 ][' content' ][' application/json' ][' ocs' ][' data' ]
208212type LibreSignAccountMe = Omit <OpenApiAccountMe , ' settings' > & {
@@ -322,7 +326,6 @@ type SignatureProfile = LibreSignUserElement
322326
323327type SignDocument = NonNullable <ReturnType <typeof useSignStore >[' document' ]>
324328type SignDocumentFile = NonNullable <SignDocument [' files' ]>[number ]
325- type SignDocumentSigner = NonNullable <SignDocument [' signers' ]>[number ]
326329
327330type SignResult = {
328331 status: ' signingInProgress' | ' signed' | ' unknown'
@@ -419,24 +422,10 @@ let requirementValidator: SigningRequirementValidator | null = null
419422let actionHandler: SignFlowHandler | null = null
420423const currentDocument = computed <SignDocument >(() => signStore .document )
421424const visibleElementsDocument = computed (() => normalizeDocumentForVisibleElements (currentDocument .value ))
425+ const currentUserSignRequestIds = computed (() => new Set (getCurrentUserSignRequestIds (visibleElementsDocument .value )))
422426
423427const elements = computed (() => {
424- const document = currentDocument .value
425- const signer = document ?.signers ?.find ((row : SignDocumentSigner ) => row .me )
426-
427- const signRequestIds = new Set <number >()
428- if (signer ?.signRequestId !== undefined ) {
429- signRequestIds .add (signer .signRequestId )
430- }
431-
432- if (Array .isArray (document ?.files )) {
433- document .files
434- .map (normalizeFileForVisibleElements )
435- .flatMap ((file ) => getFileSigners (file ))
436- .filter ((row ): row is ReturnType <typeof getFileSigners >[number ] & { me: true ; signRequestId: number } => isCurrentUserSigner (row ) && row .signRequestId !== undefined )
437- .forEach ((row ) => signRequestIds .add (row .signRequestId ))
438- }
439-
428+ const signRequestIds = currentUserSignRequestIds .value
440429 if (signRequestIds .size === 0 ) {
441430 return []
442431 }
@@ -458,13 +447,7 @@ const needCreateSignature = computed(() => {
458447 if (! canCreateSignature .value || hasSignatures .value ) {
459448 return false
460449 }
461- const document = currentDocument .value
462- const signer = document ?.signers ?.find ((row : SignDocumentSigner ) => row .me )
463- if (signer ?.signRequestId === undefined ) {
464- return false
465- }
466- const visibleElements = visibleElementsDocument .value .visibleElements || []
467- return visibleElements .some ((row ) => row .signRequestId === signer .signRequestId )
450+ return hasVisibleElementsForCurrentUser (visibleElementsDocument .value )
468451})
469452const needIdentificationDocuments = computed (() => identificationDocumentStore .showDocumentsComponent ())
470453const canCreateSignature = computed (() => {
0 commit comments