|
1 | 1 | import 'package:stacked/stacked.dart'; |
2 | 2 |
|
3 | 3 | import '../app/app.locator.dart'; |
| 4 | +import '../common/books.dart'; |
4 | 5 | import '../common/enums.dart'; |
| 6 | +import '../common/toast.dart'; |
5 | 7 | import 'json_service.dart'; |
6 | 8 | import 'settings_service.dart'; |
7 | 9 |
|
@@ -57,12 +59,27 @@ class BiblesService with ListenableServiceMixin { |
57 | 59 |
|
58 | 60 | Future<void> loadBibleVersion(Area pane) async { |
59 | 61 | if (pane == Area.primary) { |
| 62 | + revertToKJVIfOETBookNotAvailable(primaryBible, bookCode, Area.primary); |
60 | 63 | primaryAreaJson = await _jsonService.loadBookJson(primaryBible, bookCode); |
61 | 64 | } else if (pane == Area.secondary) { |
| 65 | + revertToKJVIfOETBookNotAvailable(secondaryBible, bookCode, Area.secondary); |
62 | 66 | secondaryAreaJson = await _jsonService.loadBookJson(secondaryBible, bookCode); |
63 | 67 | } |
64 | 68 | } |
65 | 69 |
|
| 70 | + void revertToKJVIfOETBookNotAvailable(String thebibleCode, String theBookCode, Area area) { |
| 71 | + // To avoid problems loading books that don't exist yet in the OET, |
| 72 | + // automatically switch to the KJV. |
| 73 | + if ((isBibleOET(thebibleCode)) && uncompletedOETBooks.contains(theBookCode)) { |
| 74 | + if (area == Area.primary) { |
| 75 | + _settingsService.setPrimaryAreaBible('KJV'); |
| 76 | + } else { |
| 77 | + _settingsService.setSecondaryAreaBible('KJV'); |
| 78 | + } |
| 79 | + showToastMsg('Book is not available in the OET yet. Reverting to the KJV.'); |
| 80 | + } |
| 81 | + } |
| 82 | + |
66 | 83 | void addBookToRecentHistory(String book) { |
67 | 84 | List<String> previousHistory = []; |
68 | 85 | previousHistory = recentBooks; |
|
0 commit comments