mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-05-26 15:16:14 +00:00
Fixed WikiTree API not always returning the Spouses field
This commit is contained in:
@@ -55,7 +55,7 @@ interface Person {
|
|||||||
FirstName: string;
|
FirstName: string;
|
||||||
LastNameAtBirth: string;
|
LastNameAtBirth: string;
|
||||||
RealName: string;
|
RealName: string;
|
||||||
Spouses: {[key: number]: Person};
|
Spouses?: {[key: number]: Person};
|
||||||
Children: {[key: number]: Person};
|
Children: {[key: number]: Person};
|
||||||
Mother: number;
|
Mother: number;
|
||||||
Father: 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(
|
const ancestors = await Promise.all(
|
||||||
[key]
|
[key]
|
||||||
.concat(spouseKeys)
|
.concat(spouseKeys)
|
||||||
@@ -317,7 +319,7 @@ export async function loadWikiTree(
|
|||||||
const people = await getRelatives(toFetch, handleCors);
|
const people = await getRelatives(toFetch, handleCors);
|
||||||
everyone.push(...people);
|
everyone.push(...people);
|
||||||
const allSpouses = people.flatMap((person) =>
|
const allSpouses = people.flatMap((person) =>
|
||||||
Object.values(person.Spouses),
|
Object.values(person.Spouses || {}),
|
||||||
);
|
);
|
||||||
everyone.push(...allSpouses);
|
everyone.push(...allSpouses);
|
||||||
// Fetch all children.
|
// Fetch all children.
|
||||||
|
|||||||
Reference in New Issue
Block a user