tweak: Moved state variable to comparisonView body
This commit is contained in:
parent
f134df4b0a
commit
958a2e366f
|
@ -5,7 +5,7 @@ import { DrawGraph, removeOldSvg } from './labeledgraph';
|
||||||
import { SubmitSliderButton } from "./slider";
|
import { SubmitSliderButton } from "./slider";
|
||||||
import { DisplayElement } from './displayElement'
|
import { DisplayElement } from './displayElement'
|
||||||
import { DisplayAsMarkdown } from './displayAsMarkdown'
|
import { DisplayAsMarkdown } from './displayAsMarkdown'
|
||||||
import { CreateTable } from './findPaths'
|
import { CreateTable, buildRows } from './findPaths'
|
||||||
import { TextAreaForJson } from "./textAreaForJson"
|
import { TextAreaForJson } from "./textAreaForJson"
|
||||||
import { pushToMongo } from "./pushToMongo.js"
|
import { pushToMongo } from "./pushToMongo.js"
|
||||||
import { maxMergeSortSteps, expectedNumMergeSortSteps } from "./utils.js"
|
import { maxMergeSortSteps, expectedNumMergeSortSteps } from "./utils.js"
|
||||||
|
@ -54,7 +54,7 @@ export default function ComparisonView({ listOfElementsForView }) {
|
||||||
let initialNumSteps = 0;
|
let initialNumSteps = 0;
|
||||||
let initialMaxSteps = maxMergeSortSteps(listOfElementsForView.length)
|
let initialMaxSteps = maxMergeSortSteps(listOfElementsForView.length)
|
||||||
let initialExpectedSteps = expectedNumMergeSortSteps(listOfElementsForView.length)
|
let initialExpectedSteps = expectedNumMergeSortSteps(listOfElementsForView.length)
|
||||||
|
let initialTableRows = []
|
||||||
//let listOfElements = listOfElementsForView.map((element, i) => ({...element, id: i}))
|
//let listOfElements = listOfElementsForView.map((element, i) => ({...element, id: i}))
|
||||||
//let list = increasingList(listOfElementsForView.length) // [0,1,2,3,4]
|
//let list = increasingList(listOfElementsForView.length) // [0,1,2,3,4]
|
||||||
//let initialComparePair = [list[list.length-2], list[list.length-1]]
|
//let initialComparePair = [list[list.length-2], list[list.length-1]]
|
||||||
|
@ -79,6 +79,7 @@ export default function ComparisonView({ listOfElementsForView }) {
|
||||||
let [numSteps, changeNumSteps] = useState(initialNumSteps);
|
let [numSteps, changeNumSteps] = useState(initialNumSteps);
|
||||||
let [maxSteps, changeMaxSteps] = useState(initialMaxSteps)
|
let [maxSteps, changeMaxSteps] = useState(initialMaxSteps)
|
||||||
let [expectedSteps, changeExpectedSteps] = useState(initialExpectedSteps)
|
let [expectedSteps, changeExpectedSteps] = useState(initialExpectedSteps)
|
||||||
|
let [tableRows, setTableRows] = useState(initialTableRows)
|
||||||
|
|
||||||
let restart = (posList) => {
|
let restart = (posList) => {
|
||||||
setToComparePair([posList[posList.length - 2], posList[posList.length - 1]])
|
setToComparePair([posList[posList.length - 2], posList[posList.length - 1]])
|
||||||
|
@ -212,10 +213,11 @@ export default function ComparisonView({ listOfElementsForView }) {
|
||||||
await pushToMongo(jsObject)
|
await pushToMongo(jsObject)
|
||||||
console.log(jsObject)
|
console.log(jsObject)
|
||||||
alert("Comparisons completed. Background work might take a while, or straight-out fail")
|
alert("Comparisons completed. Background work might take a while, or straight-out fail")
|
||||||
setTimeout(() => {
|
setTimeout(async () => {
|
||||||
// Make sure to do this after the
|
// Make sure to do this after the
|
||||||
setIsListOrdered(true)
|
setIsListOrdered(true)
|
||||||
setOrderedList(result)
|
setOrderedList(result)
|
||||||
|
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,6 +335,8 @@ export default function ComparisonView({ listOfElementsForView }) {
|
||||||
orderedList={orderedList}
|
orderedList={orderedList}
|
||||||
listOfElements={listOfElements}
|
listOfElements={listOfElements}
|
||||||
links={buildLinks(quantitativeComparisons)}
|
links={buildLinks(quantitativeComparisons)}
|
||||||
|
tableRows={tableRows}
|
||||||
|
setTableRows={setTableRows}
|
||||||
>
|
>
|
||||||
</CreateTable>
|
</CreateTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -190,8 +190,7 @@ export async function buildRows({ isListOrdered, orderedList, listOfElements, li
|
||||||
// return rows
|
// return rows
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CreateTableWithDistances({ isListOrdered, orderedList, listOfElements, links }) {
|
export function CreateTableWithDistances({ isListOrdered, orderedList, listOfElements, links, tableRows, setTableRows }) {
|
||||||
const [tableRows, setTableRows] = useState([])
|
|
||||||
|
|
||||||
useEffect(async () => {
|
useEffect(async () => {
|
||||||
await buildRows({ isListOrdered, orderedList, listOfElements, links, rows: tableRows, setTableRows })
|
await buildRows({ isListOrdered, orderedList, listOfElements, links, rows: tableRows, setTableRows })
|
||||||
|
|
Loading…
Reference in New Issue
Block a user