Skip to content

Commit 38b4573

Browse files
Revert to the KJV for bookCodes referring to incomplete OET books
1 parent 703b1c5 commit 38b4573

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

lib/services/bibles_service.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import 'package:stacked/stacked.dart';
22

33
import '../app/app.locator.dart';
4+
import '../common/books.dart';
45
import '../common/enums.dart';
6+
import '../common/toast.dart';
57
import 'json_service.dart';
68
import 'settings_service.dart';
79

@@ -57,12 +59,27 @@ class BiblesService with ListenableServiceMixin {
5759

5860
Future<void> loadBibleVersion(Area pane) async {
5961
if (pane == Area.primary) {
62+
revertToKJVIfOETBookNotAvailable(primaryBible, bookCode, Area.primary);
6063
primaryAreaJson = await _jsonService.loadBookJson(primaryBible, bookCode);
6164
} else if (pane == Area.secondary) {
65+
revertToKJVIfOETBookNotAvailable(secondaryBible, bookCode, Area.secondary);
6266
secondaryAreaJson = await _jsonService.loadBookJson(secondaryBible, bookCode);
6367
}
6468
}
6569

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+
6683
void addBookToRecentHistory(String book) {
6784
List<String> previousHistory = [];
6885
previousHistory = recentBooks;

0 commit comments

Comments
 (0)