Merge pull request 'Release' (#228) from staging into main
All checks were successful
Release to Production / build_and_release (push) Successful in 1m8s

Reviewed-on: #228
This commit is contained in:
b 2024-10-14 09:02:41 +00:00
commit bb323be87c
7 changed files with 56 additions and 39 deletions

View File

@ -1,9 +1,8 @@
import { CurrentUserMark } from '../../types/mark.ts' import { CurrentUserMark } from '../../types/mark.ts'
import styles from './style.module.scss' import styles from './style.module.scss'
import { MARK_TYPE_TRANSLATION } from '../../utils/const.ts'
import { import {
findNextIncompleteCurrentUserMark, findNextIncompleteCurrentUserMark,
getToolboxLabelByMarkType,
isCurrentUserMarksComplete, isCurrentUserMarksComplete,
isCurrentValueLast isCurrentValueLast
} from '../../utils' } from '../../utils'
@ -53,6 +52,7 @@ const MarkFormField = ({
: handleCurrentUserMarkChange(findNext()!) : handleCurrentUserMarkChange(findNext()!)
} }
const toggleActions = () => setDisplayActions(!displayActions) const toggleActions = () => setDisplayActions(!displayActions)
const markLabel = getToolboxLabelByMarkType(selectedMark.mark.type)
return ( return (
<div className={styles.container}> <div className={styles.container}>
<div className={styles.trigger}> <div className={styles.trigger}>
@ -78,16 +78,14 @@ const MarkFormField = ({
<div className={styles.actionsWrapper}> <div className={styles.actionsWrapper}>
<div className={styles.actionsTop}> <div className={styles.actionsTop}>
<div className={styles.actionsTopInfo}> <div className={styles.actionsTopInfo}>
<p className={styles.actionsTopInfoText}>Add your signature</p> <p className={styles.actionsTopInfoText}>Add {markLabel}</p>
</div> </div>
</div> </div>
<div className={styles.inputWrapper}> <div className={styles.inputWrapper}>
<form onSubmit={(e) => handleFormSubmit(e)}> <form onSubmit={(e) => handleFormSubmit(e)}>
<input <input
className={styles.input} className={styles.input}
placeholder={ placeholder={markLabel}
MARK_TYPE_TRANSLATION[selectedMark.mark.type.valueOf()]
}
onChange={handleSelectedMarkValueChange} onChange={handleSelectedMarkValueChange}
value={selectedMarkValue} value={selectedMarkValue}
/> />

View File

@ -39,6 +39,7 @@ export const MainLayout = () => {
const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState(`Loading App`) const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState(`Loading App`)
const isLoggedIn = useAppSelector((state) => state.auth?.loggedIn) const isLoggedIn = useAppSelector((state) => state.auth?.loggedIn)
const authState = useAppSelector((state) => state.auth) const authState = useAppSelector((state) => state.auth)
const usersAppData = useAppSelector((state) => state.userAppData)
// Ref to track if `subscribeForSigits` has been called // Ref to track if `subscribeForSigits` has been called
const hasSubscribed = useRef(false) const hasSubscribed = useRef(false)
@ -123,6 +124,9 @@ export const MainLayout = () => {
if (opts.type === 'login' || opts.type === 'signup') { if (opts.type === 'login' || opts.type === 'signup') {
dispatch(updateNostrLoginAuthMethod(opts.method)) dispatch(updateNostrLoginAuthMethod(opts.method))
login() login()
} else if (opts.type === 'logout') {
// Clear `subscribeForSigits` as called after the logout
hasSubscribed.current = false
} }
} }
@ -174,12 +178,10 @@ export const MainLayout = () => {
}, [dispatch]) }, [dispatch])
/** /**
* When authState change user logged in / or app reloaded * Subscribe for the sigits
* 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(() => { useEffect(() => {
if (authState && isLoggedIn) { if (authState && isLoggedIn && usersAppData) {
const pubkey = authState.usersPubkey || authState.keyPair?.public const pubkey = authState.usersPubkey || authState.keyPair?.public
if (pubkey && !hasSubscribed.current) { if (pubkey && !hasSubscribed.current) {
@ -190,6 +192,17 @@ export const MainLayout = () => {
// Mark `subscribeForSigits` as called // Mark `subscribeForSigits` as called
hasSubscribed.current = true 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) { if (pubkey) {
dispatch(setUserRobotImage(getRoboHashPicture(pubkey))) dispatch(setUserRobotImage(getRoboHashPicture(pubkey)))

View File

@ -246,17 +246,22 @@ export const CreatePage = () => {
const input = userInput.toLowerCase() const input = userInput.toLowerCase()
if (input.startsWith('npub')) { if (input.startsWith('npub')) {
const pubkey = npubToHex(input) return handleAddNpubUser(input)
if (pubkey) {
addUser(pubkey)
setUserInput('')
} else {
setError('Provided npub is not valid. Please enter correct npub.')
}
return
} }
if (input.includes('@')) { 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) setIsLoading(true)
setLoadingSpinnerDesc('Querying for nip05') setLoadingSpinnerDesc('Querying for nip05')
const nip05Profile = await queryNip05(input) const nip05Profile = await queryNip05(input)
@ -279,7 +284,16 @@ export const CreatePage = () => {
return return
} }
setError('Invalid input! Make sure to provide correct npub or nip05.') 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
}
} }
const handleUserRoleChange = (role: UserRole, pubkey: string) => { const handleUserRoleChange = (role: UserRole, pubkey: string) => {

View File

@ -536,7 +536,11 @@ export const SignPage = () => {
setIsLoading(true) setIsLoading(true)
const arrayBuffer = await decrypt(selectedFile) const arrayBuffer = await decrypt(selectedFile)
if (!arrayBuffer) return if (!arrayBuffer) {
setIsLoading(false)
toast.error('Error decrypting file')
return
}
handleDecryptedArrayBuffer(arrayBuffer) handleDecryptedArrayBuffer(arrayBuffer)
} }
@ -771,14 +775,9 @@ export const SignPage = () => {
2 2
) )
const zip = new JSZip() const zip = await getZipWithFiles(meta, files)
zip.file('meta.json', stringifiedMeta) zip.file('meta.json', stringifiedMeta)
for (const [fileName, file] of Object.entries(files)) {
zip.file(`files/${fileName}`, await file.arrayBuffer())
}
const arrayBuffer = await zip const arrayBuffer = await zip
.generateAsync({ .generateAsync({
type: 'arraybuffer', type: 'arraybuffer',
@ -807,16 +806,11 @@ export const SignPage = () => {
const handleEncryptedExport = async () => { const handleEncryptedExport = async () => {
if (Object.entries(files).length === 0 || !meta) return if (Object.entries(files).length === 0 || !meta) return
const zip = new JSZip()
const stringifiedMeta = JSON.stringify(meta, null, 2) const stringifiedMeta = JSON.stringify(meta, null, 2)
const zip = await getZipWithFiles(meta, files)
zip.file('meta.json', stringifiedMeta) zip.file('meta.json', stringifiedMeta)
for (const [fileName, file] of Object.entries(files)) {
zip.file(`files/${fileName}`, await file.arrayBuffer())
}
const arrayBuffer = await zip const arrayBuffer = await zip
.generateAsync({ .generateAsync({
type: 'arraybuffer', type: 'arraybuffer',

View File

@ -1,9 +1,4 @@
import { MarkType } from '../types/drawing.ts'
export const EMPTY: string = '' export const EMPTY: string = ''
export const MARK_TYPE_TRANSLATION: { [key: string]: string } = {
[MarkType.FULLNAME.valueOf()]: 'Full Name'
}
export const ARRAY_BUFFER = 'arraybuffer' export const ARRAY_BUFFER = 'arraybuffer'
export const DEFLATE = 'DEFLATE' export const DEFLATE = 'DEFLATE'

View File

@ -20,7 +20,7 @@ export const getZipWithFiles = async (
for (const [fileName, file] of Object.entries(files)) { for (const [fileName, file] of Object.entries(files)) {
// Handle PDF Files, add marks // Handle PDF Files, add marks
if (file.isPdf) { if (file.isPdf && fileName in marksByFileNamePage) {
const blob = await addMarks(file, marksByFileNamePage[fileName]) const blob = await addMarks(file, marksByFileNamePage[fileName])
zip.file(`marked/${fileName}`, blob) zip.file(`marked/${fileName}`, blob)
} }

View File

@ -875,7 +875,10 @@ export const subscribeForSigits = async (pubkey: string) => {
} }
const processReceivedEvent = async (event: Event, difficulty: number = 5) => { const processReceivedEvent = async (event: Event, difficulty: number = 5) => {
const processedEvents = store.getState().userAppData?.processedGiftWraps || [] const processedEvents = store.getState().userAppData?.processedGiftWraps
// Abort processing if userAppData is undefined
if (!processedEvents) return
if (processedEvents.includes(event.id)) return if (processedEvents.includes(event.id)) return