Make duplicating better: description, closetime, logscale
Known issue: some markets like https://manifold.markets/FFSX/rojo-ronald-jones don't duplicate because too much stuff in JSON...?
This commit is contained in:
parent
0cd61eb214
commit
7736f1e3c1
|
@ -33,22 +33,29 @@ export function DuplicateContractButton(props: {
|
|||
|
||||
// Pass along the Uri to create a new contract
|
||||
function duplicateContractHref(contract: Contract) {
|
||||
const descriptionString = JSON.stringify(contract.description)
|
||||
// Don't set a closeTime that's in the past
|
||||
const closeTime =
|
||||
(contract?.closeTime ?? 0) <= Date.now() ? 0 : contract.closeTime
|
||||
const params = {
|
||||
q: contract.question,
|
||||
closeTime: contract.closeTime || 0,
|
||||
description:
|
||||
(contract.description ? `${contract.description}\n\n` : '') +
|
||||
`(Copied from https://${ENV_CONFIG.domain}${contractPath(contract)})`,
|
||||
closeTime,
|
||||
description: descriptionString,
|
||||
outcomeType: contract.outcomeType,
|
||||
} as Record<string, any>
|
||||
|
||||
if (contract.outcomeType === 'PSEUDO_NUMERIC') {
|
||||
params.min = contract.min
|
||||
params.max = contract.max
|
||||
params.isLogScale = contract.isLogScale
|
||||
if (contract.isLogScale) {
|
||||
// Conditional, because `?isLogScale=false` evaluates to `true`
|
||||
params.isLogScale = true
|
||||
}
|
||||
params.initValue = getMappedValue(contract)(contract.initialProbability)
|
||||
}
|
||||
|
||||
// TODO: Support multiple choice markets?
|
||||
|
||||
if (contract.groupLinks && contract.groupLinks.length > 0) {
|
||||
params.groupId = contract.groupLinks[0].groupId
|
||||
}
|
||||
|
|
|
@ -207,6 +207,7 @@ export function NewContract(props: {
|
|||
max: MAX_DESCRIPTION_LENGTH,
|
||||
placeholder: descriptionPlaceholder,
|
||||
disabled: isSubmitting,
|
||||
defaultValue: JSON.parse(params?.description ?? '{}'),
|
||||
})
|
||||
|
||||
const isEditorFilled = editor != null && !editor.isEmpty
|
||||
|
|
Loading…
Reference in New Issue
Block a user