Skip to content

Commit

Permalink
fix: fix crash in text analysis when proper nouns disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Moseco committed Oct 1, 2024
1 parent 6fd6d57 commit 7fcc687
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/services/dictionary_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,9 @@ class DictionaryService {
Future<List<ProperNoun>> getProperNounByJapaneseTextToken(
JapaneseTextToken token,
) async {
if (token.base.contains(constants.kanjiRegExp)) {
if (_kanaKit.isKana(token.base)) {
return _database.properNounsDao.getByReading(token.base);
} else {
final results = await _database.properNounsDao.getByWritingAndReading(
token.base,
_kanaKit.toHiragana(token.baseReading),
Expand All @@ -548,8 +550,6 @@ class DictionaryService {
} else {
return results;
}
} else {
return _database.properNounsDao.getByReading(token.base);
}
}

Expand Down
2 changes: 2 additions & 0 deletions lib/ui/views/text_analysis/text_analysis_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class TextAnalysisViewModel extends FutureViewModel {
if (_sharedPreferencesService.getProperNounsEnabled()) {
token.associatedDictionaryItems =
await _dictionaryService.getProperNounByJapaneseTextToken(token);
} else {
token.associatedDictionaryItems = [];
}
} else {
token.associatedDictionaryItems =
Expand Down

0 comments on commit 7fcc687

Please sign in to comment.