Refactoring: slowly detaching data loading code from the main app

This commit is contained in:
Przemek Wiech
2020-05-12 18:26:14 +02:00
parent 7e0a72b3e9
commit 3eb48ce665
2 changed files with 205 additions and 122 deletions

View File

@@ -7,14 +7,15 @@ import {IndiInfo, JsonGedcomData} from 'topola';
*/
export function getSelection(
data: JsonGedcomData,
indi?: string,
generation?: number,
selection?: IndiInfo,
): IndiInfo {
// If ID is not given or it doesn't exist in the data, use the first ID in
// the data.
const id =
indi && data.indis.some((i) => i.id === indi) ? indi : data.indis[0].id;
return {id, generation: generation || 0};
selection && data.indis.some((i) => i.id === selection.id)
? selection.id
: data.indis[0].id;
return {id, generation: selection?.generation || 0};
}
function prepareData(