Compare commits

..

No commits in common. "3a94fbc0ae3789252e4ff2b08f5f10d89042be14" and "cc059f6cb401069b26391f18d4938ad9ef9bbf6d" have entirely different histories.

5 changed files with 59 additions and 106 deletions

View File

@ -9,7 +9,7 @@ import {
} from '@mui/material'
import styles from './style.module.scss'
import React, { useEffect, useState } from 'react'
import { ProfileMetadata, User, UserRole, KeyboardCode } from '../../types'
import { ProfileMetadata, User, UserRole } from '../../types'
import { MouseState, PdfPage, DrawnField, DrawTool } from '../../types/drawing'
import { hexToNpub, npubToHex, getProfileUsername } from '../../utils'
import { SigitFile } from '../../utils/file'
@ -41,10 +41,6 @@ export const DrawPDFFields = (props: Props) => {
const signers = users.filter((u) => u.role === UserRole.signer)
const defaultSignerNpub = signers.length ? hexToNpub(signers[0].pubkey) : ''
const [lastSigner, setLastSigner] = useState(defaultSignerNpub)
const [hideSignersForDrawnField, setHideSignersForDrawnField] = useState<{
[key: number]: boolean
} | null>()
/**
* Return first pubkey that is present in the signers list
* @param pubkeys
@ -365,7 +361,6 @@ export const DrawPDFFields = (props: Props) => {
rect
}
}
/**
* Renders the pdf pages and drawing elements
*/
@ -497,17 +492,13 @@ export const DrawPDFFields = (props: Props) => {
fileIndex,
pageIndex,
drawnFieldIndex
) &&
(!hideSignersForDrawnField ||
!hideSignersForDrawnField[drawnFieldIndex]) && (
) && (
<div
onPointerDown={handleUserSelectPointerDown}
className={styles.userSelect}
>
<FormControl fullWidth size="small">
<InputLabel id="counterparts">
Counterpart
</InputLabel>
<InputLabel id="counterparts">Counterpart</InputLabel>
<Select
value={getAvailableSigner(drawnField.counterpart)}
onChange={(event) => {
@ -523,30 +514,6 @@ export const DrawPDFFields = (props: Props) => {
renderValue={(value) =>
renderCounterpartValue(value)
}
onClose={(event: React.SyntheticEvent) => {
// get native event
const { nativeEvent } = event
// check if event is a keyboard event
if (nativeEvent instanceof KeyboardEvent) {
// check if event code is Escape
if (
nativeEvent.code === KeyboardCode.Escape
) {
// set hide signers for this DrawnField
if (hideSignersForDrawnField) {
setHideSignersForDrawnField((prev) => ({
...prev,
[drawnFieldIndex]: true
}))
} else {
setHideSignersForDrawnField({
[drawnFieldIndex]: true
})
}
}
}
}}
>
{signers.map((signer, index) => {
const npub = hexToNpub(signer.pubkey)

View File

@ -21,8 +21,7 @@ import {
ProfileMetadata,
SignedEvent,
User,
UserRole,
KeyboardCode
UserRole
} from '../../types'
import {
encryptArrayBuffer,
@ -88,10 +87,7 @@ export const CreatePage = () => {
const [userInput, setUserInput] = useState('')
const handleInputKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
if (
event.code === KeyboardCode.Enter ||
event.code === KeyboardCode.NumpadEnter
) {
if (event.code === 'Enter' || event.code === 'NumpadEnter') {
event.preventDefault()
handleAddUser()
}

View File

@ -9,7 +9,6 @@ import { toast } from 'react-toastify'
import { LoadingSpinner } from '../../components/LoadingSpinner'
import { AuthController } from '../../controllers'
import { updateKeyPair, updateLoginMethod } from '../../store/actions'
import { KeyboardCode } from '../../types'
import { LoginMethod } from '../../store/auth/types'
import { hexToBytes } from '@noble/hashes/utils'
@ -53,10 +52,7 @@ export const Nostr = () => {
* Call login function when enter is pressed
*/
const handleInputKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
if (
event.code === KeyboardCode.Enter ||
event.code === KeyboardCode.NumpadEnter
) {
if (event.code === 'Enter' || event.code === 'NumpadEnter') {
event.preventDefault()
login()
}

View File

@ -1,5 +0,0 @@
export enum KeyboardCode {
Escape = 'Escape',
Enter = 'Enter',
NumpadEnter = 'NumpadEnter'
}

View File

@ -4,4 +4,3 @@ export * from './nostr'
export * from './profile'
export * from './relay'
export * from './zip'
export * from './event'