Skip to content

Commit

Permalink
2.8.7 Tatoeba cache fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arianneorpilla committed Jul 9, 2023
1 parent cbf7ceb commit cf862b7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h3 align="center">jidoujisho</h3>
<p align="center">A full-featured immersion language learning suite for mobile.</p>
<p align="center">
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/2.8.6">
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/2.8.7">
<img src="https://img.shields.io/github/v/release/lrorpilla/jidoujisho" alt="latest release" />
</a>
<a href="https://github.com/lrorpilla/jidoujisho/commits/main">
Expand Down Expand Up @@ -34,7 +34,7 @@
---

<p align="center" style="margin:0"><b>✨ Latest Release:
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/2.8.6">2.8.6</a>
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/2.8.7">2.8.7</a>
</b></p>

<b>
Expand Down
1 change: 0 additions & 1 deletion yuuna/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ void main() {
);
}, (exception, stack) {
/// Print error details to the console.
final details = FlutterErrorDetails(exception: exception, stack: stack);

/// Log the error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TatoebaExampleSentencesEnhancement extends Enhancement {
static const String key = 'tatoeba_example_sentences';

/// Used to store results that have already been found at runtime.
final Map<String, List<String>> _tatoebaCache = {};
final Map<String, Map<String, List<String>>> _tatoebaCache = {};

/// Client used to communicate with Tatoeba.
final http.Client _client = http.Client();
Expand Down Expand Up @@ -84,8 +84,10 @@ class TatoebaExampleSentencesEnhancement extends Enhancement {
Language language = appModel.targetLanguage;
String langCode = language.threeLetterCode;

if (_tatoebaCache[langCode] != null) {
return _tatoebaCache[langCode]!;
_tatoebaCache[langCode] ??= {};

if (_tatoebaCache[langCode]![searchTerm] != null) {
return _tatoebaCache[langCode]![searchTerm]!;
}

List<String> sentences = [];
Expand All @@ -98,7 +100,7 @@ class TatoebaExampleSentencesEnhancement extends Enhancement {
List<Map<String, dynamic>>.from(json['results']);

sentences = results.map((result) => result['text'].toString()).toList();
_tatoebaCache[langCode] = sentences;
_tatoebaCache[langCode]![searchTerm] = sentences;

return sentences;
}
Expand Down
2 changes: 1 addition & 1 deletion yuuna/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: yuuna
description: A full-featured immersion language learning suite for mobile.
publish_to: 'none'
version: 2.8.6+101
version: 2.8.7+102
environment:
sdk: ">=3.0.0<4.0.0"
flutter: "^3.10.5"
Expand Down

0 comments on commit cf862b7

Please sign in to comment.