mirror of
https://github.com/PeWu/topola-viewer.git
synced 2025-12-24 03:00:05 +00:00
Fixed WikiTree API not always returning the Spouses field
This commit is contained in:
parent
4c788bc72f
commit
04a7a6b224
@ -55,7 +55,7 @@ interface Person {
|
||||
FirstName: string;
|
||||
LastNameAtBirth: string;
|
||||
RealName: string;
|
||||
Spouses: {[key: number]: Person};
|
||||
Spouses?: {[key: number]: Person};
|
||||
Children: {[key: number]: Person};
|
||||
Mother: number;
|
||||
Father: number;
|
||||
@ -250,7 +250,9 @@ export async function loadWikiTree(
|
||||
);
|
||||
}
|
||||
|
||||
const spouseKeys = Object.values(firstPerson[0].Spouses).map((s) => s.Name);
|
||||
const spouseKeys = Object.values(firstPerson[0].Spouses || {}).map(
|
||||
(s) => s.Name,
|
||||
);
|
||||
const ancestors = await Promise.all(
|
||||
[key]
|
||||
.concat(spouseKeys)
|
||||
@ -317,7 +319,7 @@ export async function loadWikiTree(
|
||||
const people = await getRelatives(toFetch, handleCors);
|
||||
everyone.push(...people);
|
||||
const allSpouses = people.flatMap((person) =>
|
||||
Object.values(person.Spouses),
|
||||
Object.values(person.Spouses || {}),
|
||||
);
|
||||
everyone.push(...allSpouses);
|
||||
// Fetch all children.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user