Better upload fee info (#2380)

* Better upload fee info

* Calculate total from info shown to user
This commit is contained in:
ekzyis 2025-08-03 19:16:16 +02:00 committed by GitHub
parent f58b853e8b
commit 1bcc864ef4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -317,10 +317,8 @@ export function MarkdownInput ({ label, topLevel, groupClassName, onChange, onKe
const [updateUploadFees] = useLazyQuery(gql` const [updateUploadFees] = useLazyQuery(gql`
query uploadFees($s3Keys: [Int]!) { query uploadFees($s3Keys: [Int]!) {
uploadFees(s3Keys: $s3Keys) { uploadFees(s3Keys: $s3Keys) {
totalFees
nUnpaid nUnpaid
uploadFees uploadFees
bytes24h
} }
}`, { }`, {
fetchPolicy: 'no-cache', fetchPolicy: 'no-cache',
@ -329,13 +327,15 @@ export function MarkdownInput ({ label, topLevel, groupClassName, onChange, onKe
console.error(err) console.error(err)
}, },
onCompleted: ({ uploadFees }) => { onCompleted: ({ uploadFees }) => {
const { uploadFees: feePerUpload, nUnpaid } = uploadFees
const totalFees = feePerUpload * nUnpaid
merge({ merge({
uploadFees: { uploadFees: {
term: `+ ${numWithUnits(uploadFees.totalFees, { abbreviate: false })}`, term: `+ ${numWithUnits(feePerUpload, { abbreviate: false })} x ${nUnpaid}`,
label: 'upload fee', label: 'upload fee',
op: '+', op: '+',
modifier: cost => cost + uploadFees.totalFees, modifier: cost => cost + totalFees,
omit: !uploadFees.totalFees omit: !totalFees
} }
}) })
} }