Compare commits
No commits in common. "bb323be87c4996153fd52c4028f5123115b233d0" and "ed90168e5d4f125966581d9828e10fd7fd2efaa7" have entirely different histories.
bb323be87c
...
ed90168e5d
@ -1,8 +1,9 @@
|
||||
import { CurrentUserMark } from '../../types/mark.ts'
|
||||
import styles from './style.module.scss'
|
||||
|
||||
import { MARK_TYPE_TRANSLATION } from '../../utils/const.ts'
|
||||
import {
|
||||
findNextIncompleteCurrentUserMark,
|
||||
getToolboxLabelByMarkType,
|
||||
isCurrentUserMarksComplete,
|
||||
isCurrentValueLast
|
||||
} from '../../utils'
|
||||
@ -52,7 +53,6 @@ const MarkFormField = ({
|
||||
: handleCurrentUserMarkChange(findNext()!)
|
||||
}
|
||||
const toggleActions = () => setDisplayActions(!displayActions)
|
||||
const markLabel = getToolboxLabelByMarkType(selectedMark.mark.type)
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div className={styles.trigger}>
|
||||
@ -78,14 +78,16 @@ const MarkFormField = ({
|
||||
<div className={styles.actionsWrapper}>
|
||||
<div className={styles.actionsTop}>
|
||||
<div className={styles.actionsTopInfo}>
|
||||
<p className={styles.actionsTopInfoText}>Add {markLabel}</p>
|
||||
<p className={styles.actionsTopInfoText}>Add your signature</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.inputWrapper}>
|
||||
<form onSubmit={(e) => handleFormSubmit(e)}>
|
||||
<input
|
||||
className={styles.input}
|
||||
placeholder={markLabel}
|
||||
placeholder={
|
||||
MARK_TYPE_TRANSLATION[selectedMark.mark.type.valueOf()]
|
||||
}
|
||||
onChange={handleSelectedMarkValueChange}
|
||||
value={selectedMarkValue}
|
||||
/>
|
||||
|
@ -39,7 +39,6 @@ export const MainLayout = () => {
|
||||
const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState(`Loading App`)
|
||||
const isLoggedIn = useAppSelector((state) => state.auth?.loggedIn)
|
||||
const authState = useAppSelector((state) => state.auth)
|
||||
const usersAppData = useAppSelector((state) => state.userAppData)
|
||||
|
||||
// Ref to track if `subscribeForSigits` has been called
|
||||
const hasSubscribed = useRef(false)
|
||||
@ -124,9 +123,6 @@ export const MainLayout = () => {
|
||||
if (opts.type === 'login' || opts.type === 'signup') {
|
||||
dispatch(updateNostrLoginAuthMethod(opts.method))
|
||||
login()
|
||||
} else if (opts.type === 'logout') {
|
||||
// Clear `subscribeForSigits` as called after the logout
|
||||
hasSubscribed.current = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,10 +174,12 @@ export const MainLayout = () => {
|
||||
}, [dispatch])
|
||||
|
||||
/**
|
||||
* Subscribe for the sigits
|
||||
* When authState change user logged in / or app reloaded
|
||||
* we set robohash avatar in the global state based on user npub
|
||||
* so that avatar will be consistent across the app when kind 0 is empty
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (authState && isLoggedIn && usersAppData) {
|
||||
if (authState && isLoggedIn) {
|
||||
const pubkey = authState.usersPubkey || authState.keyPair?.public
|
||||
|
||||
if (pubkey && !hasSubscribed.current) {
|
||||
@ -192,17 +190,6 @@ export const MainLayout = () => {
|
||||
// Mark `subscribeForSigits` as called
|
||||
hasSubscribed.current = true
|
||||
}
|
||||
}
|
||||
}, [authState, isLoggedIn, usersAppData])
|
||||
|
||||
/**
|
||||
* When authState change user logged in / or app reloaded
|
||||
* we set robohash avatar in the global state based on user npub
|
||||
* so that avatar will be consistent across the app when kind 0 is empty
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (authState && isLoggedIn) {
|
||||
const pubkey = authState.usersPubkey || authState.keyPair?.public
|
||||
|
||||
if (pubkey) {
|
||||
dispatch(setUserRobotImage(getRoboHashPicture(pubkey)))
|
||||
|
@ -246,22 +246,17 @@ export const CreatePage = () => {
|
||||
const input = userInput.toLowerCase()
|
||||
|
||||
if (input.startsWith('npub')) {
|
||||
return handleAddNpubUser(input)
|
||||
const pubkey = npubToHex(input)
|
||||
if (pubkey) {
|
||||
addUser(pubkey)
|
||||
setUserInput('')
|
||||
} else {
|
||||
setError('Provided npub is not valid. Please enter correct npub.')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (input.includes('@')) {
|
||||
return await handleAddNip05User(input)
|
||||
}
|
||||
|
||||
// If the user enters the domain (w/o @) assume it's the "root" and append _@
|
||||
// https://github.com/nostr-protocol/nips/blob/master/05.md#showing-just-the-domain-as-an-identifier
|
||||
if (input.includes('.')) {
|
||||
return await handleAddNip05User(`_@${input}`)
|
||||
}
|
||||
|
||||
setError('Invalid input! Make sure to provide correct npub or nip05.')
|
||||
|
||||
async function handleAddNip05User(input: string) {
|
||||
setIsLoading(true)
|
||||
setLoadingSpinnerDesc('Querying for nip05')
|
||||
const nip05Profile = await queryNip05(input)
|
||||
@ -284,16 +279,7 @@ export const CreatePage = () => {
|
||||
return
|
||||
}
|
||||
|
||||
function handleAddNpubUser(input: string) {
|
||||
const pubkey = npubToHex(input)
|
||||
if (pubkey) {
|
||||
addUser(pubkey)
|
||||
setUserInput('')
|
||||
} else {
|
||||
setError('Provided npub is not valid. Please enter correct npub.')
|
||||
}
|
||||
return
|
||||
}
|
||||
setError('Invalid input! Make sure to provide correct npub or nip05.')
|
||||
}
|
||||
|
||||
const handleUserRoleChange = (role: UserRole, pubkey: string) => {
|
||||
|
@ -536,11 +536,7 @@ export const SignPage = () => {
|
||||
setIsLoading(true)
|
||||
const arrayBuffer = await decrypt(selectedFile)
|
||||
|
||||
if (!arrayBuffer) {
|
||||
setIsLoading(false)
|
||||
toast.error('Error decrypting file')
|
||||
return
|
||||
}
|
||||
if (!arrayBuffer) return
|
||||
|
||||
handleDecryptedArrayBuffer(arrayBuffer)
|
||||
}
|
||||
@ -775,9 +771,14 @@ export const SignPage = () => {
|
||||
2
|
||||
)
|
||||
|
||||
const zip = await getZipWithFiles(meta, files)
|
||||
const zip = new JSZip()
|
||||
|
||||
zip.file('meta.json', stringifiedMeta)
|
||||
|
||||
for (const [fileName, file] of Object.entries(files)) {
|
||||
zip.file(`files/${fileName}`, await file.arrayBuffer())
|
||||
}
|
||||
|
||||
const arrayBuffer = await zip
|
||||
.generateAsync({
|
||||
type: 'arraybuffer',
|
||||
@ -806,11 +807,16 @@ export const SignPage = () => {
|
||||
const handleEncryptedExport = async () => {
|
||||
if (Object.entries(files).length === 0 || !meta) return
|
||||
|
||||
const zip = new JSZip()
|
||||
|
||||
const stringifiedMeta = JSON.stringify(meta, null, 2)
|
||||
const zip = await getZipWithFiles(meta, files)
|
||||
|
||||
zip.file('meta.json', stringifiedMeta)
|
||||
|
||||
for (const [fileName, file] of Object.entries(files)) {
|
||||
zip.file(`files/${fileName}`, await file.arrayBuffer())
|
||||
}
|
||||
|
||||
const arrayBuffer = await zip
|
||||
.generateAsync({
|
||||
type: 'arraybuffer',
|
||||
|
@ -1,4 +1,9 @@
|
||||
import { MarkType } from '../types/drawing.ts'
|
||||
|
||||
export const EMPTY: string = ''
|
||||
export const MARK_TYPE_TRANSLATION: { [key: string]: string } = {
|
||||
[MarkType.FULLNAME.valueOf()]: 'Full Name'
|
||||
}
|
||||
export const ARRAY_BUFFER = 'arraybuffer'
|
||||
export const DEFLATE = 'DEFLATE'
|
||||
|
||||
|
@ -20,7 +20,7 @@ export const getZipWithFiles = async (
|
||||
|
||||
for (const [fileName, file] of Object.entries(files)) {
|
||||
// Handle PDF Files, add marks
|
||||
if (file.isPdf && fileName in marksByFileNamePage) {
|
||||
if (file.isPdf) {
|
||||
const blob = await addMarks(file, marksByFileNamePage[fileName])
|
||||
zip.file(`marked/${fileName}`, blob)
|
||||
}
|
||||
|
@ -875,10 +875,7 @@ export const subscribeForSigits = async (pubkey: string) => {
|
||||
}
|
||||
|
||||
const processReceivedEvent = async (event: Event, difficulty: number = 5) => {
|
||||
const processedEvents = store.getState().userAppData?.processedGiftWraps
|
||||
|
||||
// Abort processing if userAppData is undefined
|
||||
if (!processedEvents) return
|
||||
const processedEvents = store.getState().userAppData?.processedGiftWraps || []
|
||||
|
||||
if (processedEvents.includes(event.id)) return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user