Compare commits

..

4 Commits

Author SHA1 Message Date
748cb16f9f fix: loading spinner states, timestamp the file, and lint fixes
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 33s
2024-08-08 12:49:55 +02:00
5015cefe98 refactor: update loading description 2024-08-08 12:43:49 +02:00
7b5a12246d fix(git-hooks): add executable flag 2024-08-08 12:41:39 +02:00
738a6b87f5 refactor(pdf): use minified and remove unnecessary vite config 2024-08-08 12:37:47 +02:00
7 changed files with 32 additions and 29 deletions

0
.git-hooks/commit-msg Normal file → Executable file
View File

0
.git-hooks/pre-commit Normal file → Executable file
View File

View File

@ -37,7 +37,7 @@ import { truncate } from 'lodash'
import { hexToNpub } from '../../utils' import { hexToNpub } from '../../utils'
import { toPdfFiles } from '../../utils/pdf.ts' import { toPdfFiles } from '../../utils/pdf.ts'
PDFJS.GlobalWorkerOptions.workerSrc = new URL( PDFJS.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.mjs', 'pdfjs-dist/build/pdf.worker.min.mjs',
import.meta.url import.meta.url
).toString() ).toString()

View File

@ -136,7 +136,7 @@ export const MainLayout = () => {
} }
setIsLoading(true) setIsLoading(true)
setLoadingSpinnerDesc(`Loading SIGit History`) setLoadingSpinnerDesc(`Loading SIGit history...`)
getUsersAppData() getUsersAppData()
.then((appData) => { .then((appData) => {
if (appData) { if (appData) {
@ -145,7 +145,7 @@ export const MainLayout = () => {
}) })
.finally(() => setIsLoading(false)) .finally(() => setIsLoading(false))
} }
}, [authState]) }, [authState, dispatch])
if (isLoading) return <LoadingSpinner desc={loadingSpinnerDesc} /> if (isLoading) return <LoadingSpinner desc={loadingSpinnerDesc} />

View File

@ -24,7 +24,7 @@ import JSZip from 'jszip'
import { MuiFileInput } from 'mui-file-input' import { MuiFileInput } from 'mui-file-input'
import { Event, kinds } from 'nostr-tools' import { Event, kinds } from 'nostr-tools'
import { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import { DndProvider, useDrag, useDrop } from 'react-dnd' import { DndProvider, DragSourceMonitor, useDrag, useDrop } from 'react-dnd'
import { HTML5Backend } from 'react-dnd-html5-backend' import { HTML5Backend } from 'react-dnd-html5-backend'
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
import { useLocation, useNavigate } from 'react-router-dom' import { useLocation, useNavigate } from 'react-router-dom'
@ -127,7 +127,7 @@ export const CreatePage = () => {
}) })
} }
}) })
}, []) }, [metadata, users])
// Set up event listener for authentication event // Set up event listener for authentication event
nostrController.on('nsecbunker-auth', (url) => { nostrController.on('nsecbunker-auth', (url) => {
setAuthUrl(url) setAuthUrl(url)
@ -309,14 +309,16 @@ export const CreatePage = () => {
} }
// Handle errors during file arrayBuffer conversion // Handle errors during file arrayBuffer conversion
const handleFileError = (file: File) => (err: any) => { const handleFileError = (file: File) => (err: unknown) => {
console.log( console.log(
`Error while getting arrayBuffer of file ${file.name} :>> `, `Error while getting arrayBuffer of file ${file.name} :>> `,
err err
) )
toast.error( if (err instanceof Error) {
err.message || `Error while getting arrayBuffer of file ${file.name}` toast.error(
) err.message || `Error while getting arrayBuffer of file ${file.name}`
)
}
return null return null
} }
@ -368,10 +370,12 @@ export const CreatePage = () => {
} }
// Handle errors during zip file generation // Handle errors during zip file generation
const handleZipError = (err: any) => { const handleZipError = (err: unknown) => {
console.log('Error in zip:>> ', err) console.log('Error in zip:>> ', err)
setIsLoading(false) setIsLoading(false)
toast.error(err.message || 'Error occurred in generating zip file') if (err instanceof Error) {
toast.error(err.message || 'Error occurred in generating zip file')
}
return null return null
} }
@ -438,10 +442,12 @@ export const CreatePage = () => {
} }
// Handle errors during file upload // Handle errors during file upload
const handleUploadError = (err: any) => { const handleUploadError = (err: unknown) => {
console.log('Error in upload:>> ', err) console.log('Error in upload:>> ', err)
setIsLoading(false) setIsLoading(false)
toast.error(err.message || 'Error occurred in uploading file') if (err instanceof Error) {
toast.error(err.message || 'Error occurred in uploading file')
}
return null return null
} }
@ -474,9 +480,13 @@ export const CreatePage = () => {
encryptionKey encryptionKey
) )
if (!finalZipFile) return if (!finalZipFile) {
setIsLoading(false)
return
}
saveAs(finalZipFile, 'request.sigit.zip') saveAs(finalZipFile, `request-${now()}.sigit.zip`)
setIsLoading(false)
} }
const generateFilesZip = async (): Promise<ArrayBuffer | null> => { const generateFilesZip = async (): Promise<ArrayBuffer | null> => {
@ -659,9 +669,11 @@ export const CreatePage = () => {
} }
const arrayBuffer = await generateZipFile(zip) const arrayBuffer = await generateZipFile(zip)
if (!arrayBuffer) return if (!arrayBuffer) {
setIsLoading(false)
return
}
setLoadingSpinnerDesc('Encrypting zip file')
const encryptedArrayBuffer = await encryptZipFile( const encryptedArrayBuffer = await encryptZipFile(
arrayBuffer, arrayBuffer,
encryptionKey encryptionKey
@ -967,7 +979,7 @@ const SignerRow = ({
item: () => { item: () => {
return { id: user.pubkey, index } return { id: user.pubkey, index }
}, },
collect: (monitor: any) => ({ collect: (monitor: DragSourceMonitor) => ({
isDragging: monitor.isDragging() isDragging: monitor.isDragging()
}) })
}) })

View File

@ -4,7 +4,7 @@ import { PDFDocument } from 'pdf-lib'
import { Mark } from '../types/mark.ts' import { Mark } from '../types/mark.ts'
PDFJS.GlobalWorkerOptions.workerSrc = new URL( PDFJS.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.mjs', 'pdfjs-dist/build/pdf.worker.min.mjs',
import.meta.url import.meta.url
).toString() ).toString()

View File

@ -5,15 +5,6 @@ import tsconfigPaths from 'vite-tsconfig-paths'
export default defineConfig({ export default defineConfig({
plugins: [react(), tsconfigPaths()], plugins: [react(), tsconfigPaths()],
build: { build: {
target: 'ES2022', target: 'ES2022'
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('pdfjs-dist/build/pdf.worker.mjs')) {
return 'pdf.worker'
}
}
}
}
} }
}) })