Correcting code smells
continuous-integration/drone/push Build is passing Details

master
Arthur VALIN 2 years ago
parent a511a1cc62
commit 20512045c7

2
.gitignore vendored

@ -12,4 +12,4 @@ web-build/
node_modules/ node_modules/
# macOS # macOS
.DS_Store .DS_Store
./src/test/coverage ./src/test/coverage/lcov-report/

Binary file not shown.

Binary file not shown.

@ -3,11 +3,11 @@ import { FlatList, StyleSheet, Text, useColorScheme, View } from 'react-native';
interface detailExamplesProps { interface DetailExamplesProps {
data: { japanese: string, english: string }[] data: { japanese: string, english: string }[]
} }
const DetailExamples = (props: detailExamplesProps) => { const DetailExamples = (props: DetailExamplesProps) => {
const detailExamplesStyle = useColorScheme() == 'light' ? detailExamplesStyle_light : detailExamplesStyle_dark; const detailExamplesStyle = useColorScheme() == 'light' ? detailExamplesStyle_light : detailExamplesStyle_dark;

@ -5,12 +5,12 @@ import { learnihonColors } from '../assets/colors';
interface detailRadicalProps { interface DetailRadicalProps {
character: string, character: string,
icon: string icon: string
} }
const DetailRadical = (props: detailRadicalProps) => { const DetailRadical = (props: DetailRadicalProps) => {
const detailRadicalStyle = useColorScheme() == 'light' ? detailRadicalStyle_light : detailRadicalStyle_dark; const detailRadicalStyle = useColorScheme() == 'light' ? detailRadicalStyle_light : detailRadicalStyle_dark;
return ( return (

@ -3,12 +3,12 @@ import { StyleSheet, Text, TouchableOpacity } from 'react-native';
import { Check } from "react-native-feather"; import { Check } from "react-native-feather";
import { learnihonColors } from '../assets/colors'; import { learnihonColors } from '../assets/colors';
interface gradeChipProps { interface GradeChipProps {
grade: number; grade: number;
onSelect: (item: string, isSelected: boolean) => void; onSelect: (item: string, isSelected: boolean) => void;
} }
const GradeChip = (props: gradeChipProps) => { const GradeChip = (props: GradeChipProps) => {
const [chipStyle, setChipStyle] = useState(style); const [chipStyle, setChipStyle] = useState(style);

@ -2,11 +2,11 @@ import React from "react";
import { FlatList, StyleSheet, View } from "react-native"; import { FlatList, StyleSheet, View } from "react-native";
import GradeChip from './GradeChip'; import GradeChip from './GradeChip';
interface kanjiListSeachPanelProps { interface KanjiListSeachPanelProps {
onSelect: (item: string, isSelected: boolean) => void; onSelect: (item: string, isSelected: boolean) => void;
} }
const GradeChipList = (props: kanjiListSeachPanelProps) => { const GradeChipList = (props: KanjiListSeachPanelProps) => {
return ( return (
<View style={panelStyle.container}> <View style={panelStyle.container}>

@ -1,12 +1,12 @@
import React from 'react'; import React from 'react';
import { StyleSheet, TextInput, View } from 'react-native'; import { StyleSheet, TextInput, View } from 'react-native';
interface kanjiAnswerFieldProps { interface KanjiAnswerFieldProps {
answer: string, answer: string,
setAnswer: React.Dispatch<React.SetStateAction<string>> setAnswer: React.Dispatch<React.SetStateAction<string>>
} }
const KanjiAnswerField = (props: kanjiAnswerFieldProps) => { const KanjiAnswerField = (props: KanjiAnswerFieldProps) => {
return ( return (

@ -22,7 +22,7 @@ const KanjiCard = () => {
}) })
const [loadingSvg, setLoadingSvg] = useState(false); const [loadingSvg, setLoadingSvg] = useState(false);
const [selectedItems, setSelectedItems] = useState<{ title: string, data: Kanji[] }[]>([]); const [selectedItems, setSelectedItems] = useState<{ title: string, data: Kanji[] }[]>([]);
const updateSelectedItems = (item: string, isSelected: Boolean) => { const updateSelectedItems = (item: string, isSelected: boolean) => {
if (!isSelected) { if (!isSelected) {
setSelectedItems([...selectedItems, { setSelectedItems([...selectedItems, {
title: item, title: item,
@ -53,7 +53,7 @@ const KanjiCard = () => {
const fetchXml = async () => { const fetchXml = async () => {
if (kanji) { if (kanji) {
setLoadingSvg(true); setLoadingSvg(true);
const xml = await (await fetch(kanji?.image!)).text(); const xml = await (await fetch(kanji?.image)).text();
setImgXml(xml); setImgXml(xml);
setLoadingSvg(false); setLoadingSvg(false);
} }

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react'; import React, { useState } from 'react';
import { SectionList, StyleSheet, Text, useColorScheme, View } from 'react-native'; import { SectionList, StyleSheet, Text, useColorScheme, View } from 'react-native';
import { useDispatch, useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { learnihonColors } from '../assets/colors'; import { learnihonColors } from '../assets/colors';
import { Kanji } from '../model/kanji'; import { Kanji } from '../model/kanji';
import { KanjiListByGrade } from '../model/kanjiListByGrades'; import { KanjiListByGrade } from '../model/kanjiListByGrades';

@ -6,11 +6,11 @@ import { Kanji } from '../model/kanji';
import { calcCorrectGuessesRatio, getColorByRatio } from '../model/kanjiGuess'; import { calcCorrectGuessesRatio, getColorByRatio } from '../model/kanjiGuess';
import { retrieveGuess } from '../storage/storage'; import { retrieveGuess } from '../storage/storage';
interface kanjiListCellProps { interface KanjiListCellProps {
kanji: Kanji; kanji: Kanji;
} }
const KanjiListCell = React.memo((props: kanjiListCellProps) => { const KanjiListCell = React.memo((props: KanjiListCellProps) => {
const cellStyle = useColorScheme() == 'light' ? cellStyle_light : cellStyle_dark; const cellStyle = useColorScheme() == 'light' ? cellStyle_light : cellStyle_dark;
@ -30,7 +30,7 @@ const KanjiListCell = React.memo((props: kanjiListCellProps) => {
useMemo(async () => { useMemo(async () => {
const guess = await retrieveGuess(props.kanji.character); const guess = await retrieveGuess(props.kanji.character);
const ratio = guess ? await calcCorrectGuessesRatio(guess) : -1; const ratio = guess ? calcCorrectGuessesRatio(guess) : -1;
setRatio(ratio); setRatio(ratio);
}, []); }, []);

@ -42,7 +42,6 @@ export default function Startup() {
const init = async () => { const init = async () => {
await (await fetchKanjis())(dispatch); await (await fetchKanjis())(dispatch);
//await new Promise(resolve => setTimeout(resolve, 5000));
navigator.replace("Main"); navigator.replace("Main");
} }

@ -7,7 +7,7 @@ export const retrieveGuess = async (kanji: string) => {
if (value === null) { if (value === null) {
return null; return null;
} }
const guess: KanjiGuess = await JSON.parse(value!) const guess: KanjiGuess = await JSON.parse(value)
return guess; return guess;
} catch (error) { } catch (error) {
console.log(error) console.log(error)

Loading…
Cancel
Save