fix(research): preserve verified hypothesis links after partial lookup failure (RP11)
This commit is contained in:
parent
f4cee5affa
commit
32f40ee753
3 changed files with 136 additions and 17 deletions
|
|
@ -55,7 +55,7 @@ function HypothesisReference({
|
|||
if (known) {
|
||||
setHypothesisId(known.id);
|
||||
} else {
|
||||
void Promise.all(
|
||||
void Promise.allSettled(
|
||||
candidates.map(async item => {
|
||||
const { revisions } = await researchApi.hypothesisRevisions(item.id, controller.signal);
|
||||
return revisions.some(
|
||||
|
|
@ -64,25 +64,22 @@ function HypothesisReference({
|
|||
? item.id
|
||||
: null;
|
||||
})
|
||||
)
|
||||
.then(ids => {
|
||||
if (current) {
|
||||
const found = ids.find(Boolean) ?? null;
|
||||
setHypothesisId(found);
|
||||
if (!found) {
|
||||
setError(
|
||||
'The linked hypothesis revision is unavailable in the loaded project history.'
|
||||
);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
if (current) {
|
||||
).then(results => {
|
||||
if (current) {
|
||||
const ids = results.flatMap(result =>
|
||||
result.status === 'fulfilled' ? [result.value] : []
|
||||
);
|
||||
const found = ids.find(Boolean) ?? null;
|
||||
setHypothesisId(found);
|
||||
if (!found) {
|
||||
setError(
|
||||
'Could not resolve the linked hypothesis history. Refresh the project to try again.'
|
||||
results.some(result => result.status === 'rejected')
|
||||
? 'Could not resolve the linked hypothesis history. Refresh the project to try again.'
|
||||
: 'The linked hypothesis revision is unavailable in the loaded project history.'
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return () => {
|
||||
current = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue