From b5273393e6edd56fa2e9c6b9a305e56e4555020c Mon Sep 17 00:00:00 2001 From: SwiftHawk Date: Tue, 14 May 2024 15:37:55 +0500 Subject: [PATCH] fix: remove both from UserRole enum --- src/pages/sign/index.tsx | 10 ++-------- src/pages/verify/index.tsx | 17 +++-------------- src/types/core.ts | 3 +-- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/pages/sign/index.tsx b/src/pages/sign/index.tsx index 7bf543d..7e25cc9 100644 --- a/src/pages/sign/index.tsx +++ b/src/pages/sign/index.tsx @@ -218,12 +218,8 @@ export const SignPage = () => { zip.file(`files/${file.name}`, file) }) - const signers = users.filter( - (user) => user.role === UserRole.signer || user.role === UserRole.both - ) - const viewers = users.filter( - (user) => user.role === UserRole.viewer || user.role === UserRole.both - ) + const signers = users.filter((user) => user.role === UserRole.signer) + const viewers = users.filter((user) => user.role === UserRole.viewer) setLoadingSpinnerDesc('Signing nostr event') const signedEvent = await signEventForMetaFile( @@ -398,7 +394,6 @@ export const SignPage = () => { > {UserRole.signer} {UserRole.viewer} - {UserRole.both} @@ -527,7 +522,6 @@ const DisplayUser = ({ {UserRole.viewer} - {UserRole.both} diff --git a/src/pages/verify/index.tsx b/src/pages/verify/index.tsx index fda3a10..efff90e 100644 --- a/src/pages/verify/index.tsx +++ b/src/pages/verify/index.tsx @@ -581,10 +581,6 @@ const DisplayMeta = ({ meta, nextSigner }: DisplayMetaProps) => { useEffect(() => { meta.signers.forEach((signer) => { - const userRole = meta.viewers.includes(signer) - ? UserRole.both - : UserRole.signer - setUsers((prev) => { if (prev.findIndex((user) => user.pubkey === signer) !== -1) return prev @@ -592,17 +588,13 @@ const DisplayMeta = ({ meta, nextSigner }: DisplayMetaProps) => { ...prev, { pubkey: signer, - role: userRole + role: UserRole.signer } ] }) }) meta.viewers.forEach((viewer) => { - const userRole = meta.signers.includes(viewer) - ? UserRole.both - : UserRole.viewer - setUsers((prev) => { if (prev.findIndex((user) => user.pubkey === viewer) !== -1) return prev @@ -610,7 +602,7 @@ const DisplayMeta = ({ meta, nextSigner }: DisplayMetaProps) => { ...prev, { pubkey: viewer, - role: userRole + role: UserRole.viewer } ] }) @@ -760,10 +752,7 @@ const DisplayMeta = ({ meta, nextSigner }: DisplayMetaProps) => { if (user.role === UserRole.viewer) { signedStatus = '-' - } else if ( - user.role === UserRole.signer || - user.role === UserRole.both - ) { + } else { // check if user has signed the document if (user.pubkey in meta.signedEvents) { signedStatus = 'Signed' diff --git a/src/types/core.ts b/src/types/core.ts index ef0af52..531e1fd 100644 --- a/src/types/core.ts +++ b/src/types/core.ts @@ -1,7 +1,6 @@ export enum UserRole { signer = 'Signer', - viewer = 'Viewer', - both = 'Both' + viewer = 'Viewer' } export interface User {