mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-07-26 05:31:48 +00:00
Improve code quality
Fix lint warnings
This commit is contained in:
@@ -33,9 +33,9 @@ export interface EmbeddedSourceSpec {
|
||||
/** GEDCOM file received from outside of the iframe. */
|
||||
export class EmbeddedDataSource implements DataSource<EmbeddedSourceSpec> {
|
||||
isNewData(
|
||||
newSource: SourceSelection<EmbeddedSourceSpec>,
|
||||
oldSource: SourceSelection<EmbeddedSourceSpec>,
|
||||
data?: TopolaData,
|
||||
_newSource: SourceSelection<EmbeddedSourceSpec>,
|
||||
_oldSource: SourceSelection<EmbeddedSourceSpec>,
|
||||
_data?: TopolaData,
|
||||
): boolean {
|
||||
// Never reload data.
|
||||
return false;
|
||||
@@ -44,7 +44,7 @@ export class EmbeddedDataSource implements DataSource<EmbeddedSourceSpec> {
|
||||
private async onMessage(
|
||||
message: EmbeddedMessage,
|
||||
resolve: (value: TopolaData) => void,
|
||||
reject: (reason: any) => void,
|
||||
reject: (reason: unknown) => void,
|
||||
) {
|
||||
if (message.message === EmbeddedMessageType.PARENT_READY) {
|
||||
// Parent didn't receive the first 'ready' message, so we need to send it again.
|
||||
@@ -69,7 +69,7 @@ export class EmbeddedDataSource implements DataSource<EmbeddedSourceSpec> {
|
||||
}
|
||||
|
||||
async loadData(
|
||||
source: SourceSelection<EmbeddedSourceSpec>,
|
||||
_source: SourceSelection<EmbeddedSourceSpec>,
|
||||
): Promise<TopolaData> {
|
||||
// Notify the parent window that we are ready.
|
||||
return new Promise<TopolaData>((resolve, reject) => {
|
||||
|
||||
@@ -27,7 +27,8 @@ const MONTHS = new Map<number, string>([
|
||||
]);
|
||||
|
||||
function dateToGedcom(date: Date): string {
|
||||
return [date.qualifier, date.day, MONTHS.get(date.month!), date.year]
|
||||
const month = (date.month && MONTHS.get(date.month)) || undefined;
|
||||
return [date.qualifier, date.day, month, date.year]
|
||||
.filter((x) => x !== undefined)
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
@@ -151,13 +151,18 @@ export interface UploadSourceSpec {
|
||||
images?: Map<string, string>;
|
||||
}
|
||||
|
||||
export interface UploadLocationState {
|
||||
data: string;
|
||||
images: Map<string, string>;
|
||||
}
|
||||
|
||||
/** Files opened from the local computer. */
|
||||
export class UploadedDataSource implements DataSource<UploadSourceSpec> {
|
||||
// isNewData(args: Arguments, state: State): boolean {
|
||||
isNewData(
|
||||
newSource: SourceSelection<UploadSourceSpec>,
|
||||
oldSource: SourceSelection<UploadSourceSpec>,
|
||||
data?: TopolaData,
|
||||
_data?: TopolaData,
|
||||
): boolean {
|
||||
return newSource.spec.hash !== oldSource.spec.hash;
|
||||
}
|
||||
@@ -196,7 +201,7 @@ export class GedcomUrlDataSource implements DataSource<UrlSourceSpec> {
|
||||
isNewData(
|
||||
newSource: SourceSelection<UrlSourceSpec>,
|
||||
oldSource: SourceSelection<UrlSourceSpec>,
|
||||
data?: TopolaData,
|
||||
_data?: TopolaData,
|
||||
): boolean {
|
||||
return newSource.spec.url !== oldSource.spec.url;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ export async function loadWikiTree(
|
||||
.filter((person) => person.PhotoData?.path)
|
||||
.map((person) => [
|
||||
person.Name,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
`https://www.wikitree.com${person.PhotoData!.path}`,
|
||||
]),
|
||||
);
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import {IntlShape} from 'react-intl';
|
||||
import {DateOrRange, JsonEvent, JsonFam, JsonImage, JsonIndi} from 'topola';
|
||||
import {
|
||||
Date,
|
||||
DateOrRange,
|
||||
JsonEvent,
|
||||
JsonFam,
|
||||
JsonImage,
|
||||
JsonIndi,
|
||||
} from 'topola';
|
||||
import {StringUtils} from 'turbocommons-ts';
|
||||
import {Person} from 'wikitree-js';
|
||||
import {PRIVATE_ID_PREFIX} from './wikitree_api';
|
||||
@@ -274,7 +281,7 @@ function parseDate(date: string, dataStatus?: string): DateOrRange | undefined {
|
||||
if (!matchedDate) {
|
||||
return {date: {text: date}};
|
||||
}
|
||||
const parsedDate: any = {};
|
||||
const parsedDate: Date = {};
|
||||
if (matchedDate[1] !== '0000') {
|
||||
parsedDate.year = ~~matchedDate[1];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user