Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix crash in text analysis when proper nouns disabled #30

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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