From 7736f1e3c190d71fa7054a0b79ad737256473527 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Mon, 22 Aug 2022 10:49:54 -0700 Subject: [PATCH] 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...? --- web/components/copy-contract-button.tsx | 17 ++++++++++++----- web/pages/create.tsx | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/web/components/copy-contract-button.tsx b/web/components/copy-contract-button.tsx index 8536df71..cb23776c 100644 --- a/web/components/copy-contract-button.tsx +++ b/web/components/copy-contract-button.tsx @@ -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 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 } diff --git a/web/pages/create.tsx b/web/pages/create.tsx index 52f2a373..2ec86bb7 100644 --- a/web/pages/create.tsx +++ b/web/pages/create.tsx @@ -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