store-sigits and update working flow #116

Merged
b merged 18 commits from store-sigits into staging 2024-07-11 11:42:19 +00:00
Showing only changes of commit ef5376e2d1 - Show all commits

View File

@ -60,6 +60,23 @@ import {
import styles from './style.module.scss'
import { appPrivateRoutes } from '../../routes'
/**
* Helper function to get the current timestamp in YYMMDD:HHMMSS format
*/
const getFormattedTimestamp = () => {
const now = new Date()
const padZero = (num: number) => (num < 10 ? '0' + num : num)
const year = now.getFullYear()
const month = padZero(now.getMonth() + 1) // Months are zero-indexed
const day = padZero(now.getDate())
const hours = padZero(now.getHours())
const minutes = padZero(now.getMinutes())
const seconds = padZero(now.getSeconds())
return `${year}-${month}-${day}_${hours}:${minutes}:${seconds}`
}
export const CreatePage = () => {
const navigate = useNavigate()
const location = useLocation()
@ -70,7 +87,7 @@ export const CreatePage = () => {
const [authUrl, setAuthUrl] = useState<string>()
const [title, setTitle] = useState('')
const [title, setTitle] = useState(`sigit_${getFormattedTimestamp()}`)
const [selectedFiles, setSelectedFiles] = useState<File[]>([])
const [userInput, setUserInput] = useState('')
@ -454,19 +471,19 @@ export const CreatePage = () => {
setLoadingSpinnerDesc('Signing nostr event for create signature')
try {
const createSignature = await signEventForMetaFile(
JSON.stringify(content),
nostrController,
setIsLoading
)
if (!createSignature) return null
return JSON.stringify(createSignature, null, 2)
} catch (error) {
const createSignature = await signEventForMetaFile(
JSON.stringify(content),
nostrController,
setIsLoading
).catch(() => {
console.log('An error occurred in signing event for meta file', error)
toast.error('An error occurred in signing event for meta file')
return null
}
})
if (!createSignature) return null
return JSON.stringify(createSignature, null, 2)
}
// Send notifications to signers and viewers
@ -580,7 +597,10 @@ export const CreatePage = () => {
setLoadingSpinnerDesc('Generating create signature')
const createSignature = await generateCreateSignature(fileHashes, '')
if (!createSignature) return
if (!createSignature) {
setIsLoading(false)
return
}
const meta: Meta = {
createSignature,