Skip to content

Commit

Permalink
do not add duplicate words to list
Browse files Browse the repository at this point in the history
  • Loading branch information
krmanik committed Apr 29, 2024
1 parent 435c6ed commit be47b23
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pages/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export default function CreateDeck(): JSX.Element {
let res = DICT.search(word);
let result = await DICT.makeHtml(res, true);

if (words.some((w) => w.Simplified === result[0].simplified)) {
if (words.some((w) => w.Simplified === word.trim())) {
return;
}

Expand Down Expand Up @@ -340,7 +340,11 @@ export default function CreateDeck(): JSX.Element {
}
}

if (words.some((w) => w.Simplified === result[0].simplified)) {
if (words.some((w) => w.Simplified === line.trim())) {
continue;
}

if (_words.some((w) => w.Simplified === line.trim())) {
continue;
}

Expand Down Expand Up @@ -408,6 +412,7 @@ export default function CreateDeck(): JSX.Element {

let cutWords = cut(text, true);
cutWords = filterChineseWords(cutWords);
cutWords = [...new Set(cutWords)];

for (let word of cutWords) {
let res = DICT.search(word);
Expand All @@ -432,7 +437,7 @@ export default function CreateDeck(): JSX.Element {
}
}

if (words.some((w) => w.Simplified === result[0].simplified)) {
if (words.some((w) => w.Simplified === word.trim())) {
continue;
}

Expand Down

0 comments on commit be47b23

Please sign in to comment.