Releasing new design #161

Merged
b merged 241 commits from staging into main 2024-08-21 11:38:25 +00:00
5 changed files with 26 additions and 14 deletions
Showing only changes of commit 61f39d17ff - Show all commits

View File

@ -7,7 +7,7 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 10", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 6",
"lint:fix": "eslint . --fix --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "lint:fix": "eslint . --fix --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:staged": "eslint --fix --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "lint:staged": "eslint --fix --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"formatter:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"", "formatter:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",

View File

@ -236,11 +236,13 @@ export const SignPage = () => {
if (!arrayBuffer) return if (!arrayBuffer) return
const blob = new Blob([arrayBuffer]) const blob = new Blob([arrayBuffer])
saveAs(blob, `exported-${unixNow()}.sigit.zip`) saveAs(blob, `exported-${unixNow()}.sigit.zip`)
} catch (error: any) { } catch (error) {
console.log('error in zip:>> ', error) console.log('error in zip:>> ', error)
if (error instanceof Error) {
toast.error(error.message || 'Error occurred in generating zip file') toast.error(error.message || 'Error occurred in generating zip file')
} }
} }
}
const decrypt = useCallback( const decrypt = useCallback(
async (file: File) => { async (file: File) => {

View File

@ -141,7 +141,7 @@ export const DisplayMeta = ({
}) })
} }
}) })
}, [users, submittedBy]) }, [users, submittedBy, metadata])
const downloadFile = async (filename: string) => { const downloadFile = async (filename: string) => {
const arrayBuffer = await files[filename].file.arrayBuffer() const arrayBuffer = await files[filename].file.arrayBuffer()

View File

@ -1,9 +1,11 @@
export class DecryptionError extends Error { export class DecryptionError extends Error {
public message: string = '' public message: string = ''
constructor(public inputError: any) { constructor(public inputError: unknown) {
super() super()
// Make sure inputError has access to the .message
if (inputError instanceof Error) {
if (inputError.message.toLowerCase().includes('expected')) { if (inputError.message.toLowerCase().includes('expected')) {
this.message = `The decryption key length or format is invalid.` this.message = `The decryption key length or format is invalid.`
} else if ( } else if (
@ -14,6 +16,12 @@ export class DecryptionError extends Error {
this.message = this.message =
inputError.message || 'An error occurred while decrypting file.' inputError.message || 'An error occurred while decrypting file.'
} }
} else {
// We don't have message on the inputError
// Stringify whole error and set that as a message
this.message =
JSON.stringify(inputError) || 'An error occurred while decrypting file.'
}
this.name = 'DecryptionError' this.name = 'DecryptionError'
Object.setPrototypeOf(this, DecryptionError.prototype) Object.setPrototypeOf(this, DecryptionError.prototype)

View File

@ -37,9 +37,11 @@ const readContentOfZipEntry = async <T extends OutputType>(
const loadZip = async (data: InputFileFormat): Promise<JSZip | null> => { const loadZip = async (data: InputFileFormat): Promise<JSZip | null> => {
try { try {
return await JSZip.loadAsync(data) return await JSZip.loadAsync(data)
} catch (err: any) { } catch (err) {
console.log('err in loading zip file :>> ', err) console.log('err in loading zip file :>> ', err)
if (err instanceof Error) {
toast.error(err.message || 'An error occurred in loading zip file.') toast.error(err.message || 'An error occurred in loading zip file.')
}
return null return null
} }
} }