Skip to content

Commit

Permalink
Fix critical crash bug related to duplicate checks
Browse files Browse the repository at this point in the history
  • Loading branch information
arianneorpilla committed Jun 4, 2023
1 parent 5558668 commit 9e8c3e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions yuuna/lib/src/creator/actions/instant_export_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class InstantExportAction extends QuickAction {
required DictionaryHeading heading,
required String? dictionaryName,
}) async {
await appModel.getModelList();
CreatorModel creatorModel = ref.read(instantExportProvider);

Map<Field, String> newTextFields = {};
Expand Down
25 changes: 15 additions & 10 deletions yuuna/lib/src/models/app_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ class AppModel with ChangeNotifier {

/// Shows the AnkiDroid API message. Called when an Anki-related API get call
/// fails.
void showAnkidroidApiMessage() async {
Future<void> showAnkidroidApiMessage() async {
await requestAnkidroidPermissions();

await showDialog(
Expand Down Expand Up @@ -1971,7 +1971,7 @@ class AppModel with ChangeNotifier {
decks.sort((a, b) => a.compareTo(b));
return decks;
} catch (e) {
showAnkidroidApiMessage();
await showAnkidroidApiMessage();
rethrow;
}
}
Expand All @@ -1987,7 +1987,7 @@ class AppModel with ChangeNotifier {
models.sort((a, b) => a.compareTo(b));
return models;
} catch (e) {
showAnkidroidApiMessage();
await showAnkidroidApiMessage();
rethrow;
}
}
Expand Down Expand Up @@ -2015,13 +2015,18 @@ class AppModel with ChangeNotifier {
/// Given a value and a model name, checks if there are cards that have a
/// first field with a matching value.
Future<bool> checkForDuplicates(String key) async {
return await methodChannel.invokeMethod(
'checkForDuplicates',
<String, dynamic>{
'models': duplicateCheckModels,
'key': key,
},
);
try {
final result = await methodChannel.invokeMethod(
'checkForDuplicates',
<String, dynamic>{
'models': duplicateCheckModels,
'key': key,
},
);
return result;
} catch (e) {
return false;
}
}

/// Add a note with certain [creatorFieldValues] and a [mapping] of fields to
Expand Down

0 comments on commit 9e8c3e2

Please sign in to comment.