Compare commits

..

No commits in common. "7bb83695c9e41627df1aab665abcf6b6cdbd4078" and "603b01d4004e00714b4400fe2a3391e29dde44d3" have entirely different histories.

7 changed files with 20 additions and 71 deletions

View File

@ -1,14 +1,13 @@
import { PdfFile } from '../../types/drawing.ts' import { PdfFile } from '../../types/drawing.ts'
import { CurrentUserMark, Mark } from '../../types/mark.ts' import { CurrentUserMark } from '../../types/mark.ts'
import PdfPageItem from './PdfPageItem.tsx' import PdfPageItem from './PdfPageItem.tsx'
interface PdfItemProps { interface PdfItemProps {
pdfFile: PdfFile
currentUserMarks: CurrentUserMark[] currentUserMarks: CurrentUserMark[]
handleMarkClick: (id: number) => void handleMarkClick: (id: number) => void
otherUserMarks: Mark[]
pdfFile: PdfFile
selectedMark: CurrentUserMark | null
selectedMarkValue: string selectedMarkValue: string
selectedMark: CurrentUserMark | null
} }
/** /**
@ -19,8 +18,7 @@ const PdfItem = ({
currentUserMarks, currentUserMarks,
handleMarkClick, handleMarkClick,
selectedMarkValue, selectedMarkValue,
selectedMark, selectedMark
otherUserMarks
}: PdfItemProps) => { }: PdfItemProps) => {
const filterByPage = ( const filterByPage = (
marks: CurrentUserMark[], marks: CurrentUserMark[],
@ -28,9 +26,6 @@ const PdfItem = ({
): CurrentUserMark[] => { ): CurrentUserMark[] => {
return marks.filter((m) => m.mark.location.page === page) return marks.filter((m) => m.mark.location.page === page)
} }
const filterMarksByPage = (marks: Mark[], page: number): Mark[] => {
return marks.filter((mark) => mark.location.page === page)
}
return pdfFile.pages.map((page, i) => { return pdfFile.pages.map((page, i) => {
return ( return (
<PdfPageItem <PdfPageItem
@ -40,7 +35,6 @@ const PdfItem = ({
handleMarkClick={handleMarkClick} handleMarkClick={handleMarkClick}
selectedMarkValue={selectedMarkValue} selectedMarkValue={selectedMarkValue}
selectedMark={selectedMark} selectedMark={selectedMark}
otherUserMarks={filterMarksByPage(otherUserMarks, i)}
/> />
) )
}) })

View File

@ -18,14 +18,13 @@ import { UsersDetails } from '../UsersDetails.tsx'
import { Meta } from '../../types' import { Meta } from '../../types'
interface PdfMarkingProps { interface PdfMarkingProps {
currentUserMarks: CurrentUserMark[]
files: CurrentUserFile[] files: CurrentUserFile[]
currentUserMarks: CurrentUserMark[]
setIsReadyToSign: (isReadyToSign: boolean) => void
setCurrentUserMarks: (currentUserMarks: CurrentUserMark[]) => void
setUpdatedMarks: (markToUpdate: Mark) => void
handleDownload: () => void handleDownload: () => void
meta: Meta | null meta: Meta | null
otherUserMarks: Mark[]
setCurrentUserMarks: (currentUserMarks: CurrentUserMark[]) => void
setIsReadyToSign: (isReadyToSign: boolean) => void
setUpdatedMarks: (markToUpdate: Mark) => void
} }
/** /**
@ -42,8 +41,7 @@ const PdfMarking = (props: PdfMarkingProps) => {
setCurrentUserMarks, setCurrentUserMarks,
setUpdatedMarks, setUpdatedMarks,
handleDownload, handleDownload,
meta, meta
otherUserMarks
} = props } = props
const [selectedMark, setSelectedMark] = useState<CurrentUserMark | null>(null) const [selectedMark, setSelectedMark] = useState<CurrentUserMark | null>(null)
const [selectedMarkValue, setSelectedMarkValue] = useState<string>('') const [selectedMarkValue, setSelectedMarkValue] = useState<string>('')
@ -144,7 +142,6 @@ const PdfMarking = (props: PdfMarkingProps) => {
selectedMarkValue={selectedMarkValue} selectedMarkValue={selectedMarkValue}
selectedMark={selectedMark} selectedMark={selectedMark}
currentUserMarks={currentUserMarks} currentUserMarks={currentUserMarks}
otherUserMarks={otherUserMarks}
/> />
</div> </div>
)} )}

View File

@ -1,17 +1,14 @@
import styles from '../DrawPDFFields/style.module.scss' import styles from '../DrawPDFFields/style.module.scss'
import { PdfPage } from '../../types/drawing.ts' import { PdfPage } from '../../types/drawing.ts'
import { CurrentUserMark, Mark } from '../../types/mark.ts' import { CurrentUserMark } from '../../types/mark.ts'
import PdfMarkItem from './PdfMarkItem.tsx' import PdfMarkItem from './PdfMarkItem.tsx'
import { useEffect, useRef } from 'react' import { useEffect, useRef } from 'react'
import pdfViewStyles from './style.module.scss'
import { inPx } from '../../utils/pdf.ts'
interface PdfPageProps { interface PdfPageProps {
page: PdfPage
currentUserMarks: CurrentUserMark[] currentUserMarks: CurrentUserMark[]
handleMarkClick: (id: number) => void handleMarkClick: (id: number) => void
otherUserMarks: Mark[]
page: PdfPage
selectedMark: CurrentUserMark | null
selectedMarkValue: string selectedMarkValue: string
selectedMark: CurrentUserMark | null
} }
/** /**
@ -22,8 +19,7 @@ const PdfPageItem = ({
currentUserMarks, currentUserMarks,
handleMarkClick, handleMarkClick,
selectedMarkValue, selectedMarkValue,
selectedMark, selectedMark
otherUserMarks
}: PdfPageProps) => { }: PdfPageProps) => {
useEffect(() => { useEffect(() => {
if (selectedMark !== null && !!markRefs.current[selectedMark.id]) { if (selectedMark !== null && !!markRefs.current[selectedMark.id]) {
@ -53,20 +49,6 @@ const PdfPageItem = ({
/> />
</div> </div>
))} ))}
{otherUserMarks.map((m, i) => (
<div
key={i}
className={pdfViewStyles.otherUserMarksDisplay}
style={{
left: inPx(m.location.left),
top: inPx(m.location.top),
width: inPx(m.location.width),
height: inPx(m.location.height)
}}
>
{m.value}
</div>
))}
</div> </div>
) )
} }

View File

@ -1,17 +1,16 @@
import { Divider } from '@mui/material' import { Divider } from '@mui/material'
import PdfItem from './PdfItem.tsx' import PdfItem from './PdfItem.tsx'
import { CurrentUserMark, Mark } from '../../types/mark.ts' import { CurrentUserMark } from '../../types/mark.ts'
import { CurrentUserFile } from '../../types/file.ts' import { CurrentUserFile } from '../../types/file.ts'
import { useEffect, useRef } from 'react' import { useEffect, useRef } from 'react'
interface PdfViewProps { interface PdfViewProps {
currentFile: CurrentUserFile | null
currentUserMarks: CurrentUserMark[]
files: CurrentUserFile[] files: CurrentUserFile[]
currentUserMarks: CurrentUserMark[]
handleMarkClick: (id: number) => void handleMarkClick: (id: number) => void
otherUserMarks: Mark[]
selectedMark: CurrentUserMark | null
selectedMarkValue: string selectedMarkValue: string
selectedMark: CurrentUserMark | null
currentFile: CurrentUserFile | null
} }
/** /**
@ -23,8 +22,7 @@ const PdfView = ({
handleMarkClick, handleMarkClick,
selectedMarkValue, selectedMarkValue,
selectedMark, selectedMark,
currentFile, currentFile
otherUserMarks
}: PdfViewProps) => { }: PdfViewProps) => {
const pdfRefs = useRef<(HTMLDivElement | null)[]>([]) const pdfRefs = useRef<(HTMLDivElement | null)[]>([])
useEffect(() => { useEffect(() => {
@ -43,9 +41,6 @@ const PdfView = ({
(currentUserMark) => currentUserMark.mark.pdfFileHash === hash (currentUserMark) => currentUserMark.mark.pdfFileHash === hash
) )
} }
const filterMarksByFile = (marks: Mark[], hash: string): Mark[] => {
return marks.filter((mark) => mark.pdfFileHash === hash)
}
const isNotLastPdfFile = (index: number, files: CurrentUserFile[]): boolean => const isNotLastPdfFile = (index: number, files: CurrentUserFile[]): boolean =>
index !== files.length - 1 index !== files.length - 1
return ( return (
@ -65,7 +60,6 @@ const PdfView = ({
selectedMark={selectedMark} selectedMark={selectedMark}
handleMarkClick={handleMarkClick} handleMarkClick={handleMarkClick}
selectedMarkValue={selectedMarkValue} selectedMarkValue={selectedMarkValue}
otherUserMarks={filterMarksByFile(otherUserMarks, hash)}
/> />
{isNotLastPdfFile(index, arr) && <Divider>File Separator</Divider>} {isNotLastPdfFile(index, arr) && <Divider>File Separator</Divider>}
</div> </div>

View File

@ -29,11 +29,3 @@
height: 100%; height: 100%;
gap: 10px; gap: 10px;
} }
.otherUserMarksDisplay {
position: absolute;
z-index: 50;
display: flex;
justify-content: center;
align-items: center;
}

View File

@ -32,8 +32,7 @@ import {
readContentOfZipEntry, readContentOfZipEntry,
sendNotification, sendNotification,
signEventForMetaFile, signEventForMetaFile,
updateUsersAppData, updateUsersAppData
findOtherUserMarks
} from '../../utils' } from '../../utils'
import { Container } from '../../components/Container' import { Container } from '../../components/Container'
import { DisplayMeta } from './internal/displayMeta' import { DisplayMeta } from './internal/displayMeta'
@ -111,7 +110,6 @@ export const SignPage = () => {
[] []
) )
const [isReadyToSign, setIsReadyToSign] = useState(false) const [isReadyToSign, setIsReadyToSign] = useState(false)
const [otherUserMarks, setOtherUserMarks] = useState<Mark[]>([])
useEffect(() => { useEffect(() => {
if (signers.length > 0) { if (signers.length > 0) {
@ -211,8 +209,6 @@ export const SignPage = () => {
) )
const signedMarks = extractMarksFromSignedMeta(meta) const signedMarks = extractMarksFromSignedMeta(meta)
const currentUserMarks = getCurrentUserMarks(metaMarks, signedMarks) const currentUserMarks = getCurrentUserMarks(metaMarks, signedMarks)
const otherUserMarks = findOtherUserMarks(signedMarks, usersPubkey!)
setOtherUserMarks(otherUserMarks)
setCurrentUserMarks(currentUserMarks) setCurrentUserMarks(currentUserMarks)
setIsReadyToSign(isCurrentUserMarksComplete(currentUserMarks)) setIsReadyToSign(isCurrentUserMarksComplete(currentUserMarks))
} }
@ -964,7 +960,6 @@ export const SignPage = () => {
setCurrentUserMarks={setCurrentUserMarks} setCurrentUserMarks={setCurrentUserMarks}
setUpdatedMarks={setUpdatedMarks} setUpdatedMarks={setUpdatedMarks}
handleDownload={handleDownload} handleDownload={handleDownload}
otherUserMarks={otherUserMarks}
meta={meta} meta={meta}
/> />
) )

View File

@ -127,10 +127,6 @@ const getUpdatedMark = (
} }
} }
const findOtherUserMarks = (marks: Mark[], pubkey: string): Mark[] => {
return marks.filter((mark) => mark.npub !== hexToNpub(pubkey))
}
export { export {
getCurrentUserMarks, getCurrentUserMarks,
filterMarksByPubkey, filterMarksByPubkey,
@ -140,6 +136,5 @@ export {
updateMarks, updateMarks,
updateCurrentUserMarks, updateCurrentUserMarks,
isCurrentValueLast, isCurrentValueLast,
getUpdatedMark, getUpdatedMark
findOtherUserMarks
} }