fix(research): keep experiment choices after linked template failure (RP10)
This commit is contained in:
parent
49da701aa7
commit
f0e7d07476
5 changed files with 230 additions and 8 deletions
|
|
@ -30,13 +30,23 @@ export function useExperimentTemplates(initialBacktestId: string) {
|
|||
if (!Array.isArray(rows)) {
|
||||
throw new Error('The saved backtest list could not be read');
|
||||
}
|
||||
const selected =
|
||||
initialBacktestId && !rows.some(item => item?.id === initialBacktestId)
|
||||
? await backtestApiV2.getBacktest(initialBacktestId)
|
||||
: null;
|
||||
if (current) {
|
||||
setMoreTemplates(rows.length === limit);
|
||||
setBacktests((selected ? [...rows, selected] : rows).filter(canonical));
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
setMoreTemplates(rows.length === limit);
|
||||
setBacktests(rows.filter(canonical));
|
||||
if (initialBacktestId && !rows.some(item => item?.id === initialBacktestId)) {
|
||||
// A missing linked template must not hide the successfully loaded catalog.
|
||||
try {
|
||||
const selected = await backtestApiV2.getBacktest(initialBacktestId);
|
||||
if (current) {
|
||||
setBacktests([...rows, selected].filter(canonical));
|
||||
}
|
||||
} catch (cause) {
|
||||
if (current) {
|
||||
setTemplateError(`Could not load the selected backtest: ${message(cause)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
})()
|
||||
.catch(cause => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue