Skip to content

Commit 7a1dfec

Browse files
committed
feat: add error message for retrying after an error occurs in multiple languages
1 parent e25c831 commit 7a1dfec

File tree

9 files changed

+55
-35
lines changed

9 files changed

+55
-35
lines changed

lib/locales/de.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
},
301301
"errors": {
302302
"errorOccurred": "Ein Fehler ist aufgetreten",
303-
"unknownError": "Unbekannter Fehler"
303+
"unknownError": "Unbekannter Fehler",
304+
"errorOccurredTryAgain": "Ein Fehler ist aufgetreten, bitte versuchen Sie es erneut."
304305
}
305306
}

lib/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
},
301301
"errors": {
302302
"errorOccurred": "An error occurred",
303-
"unknownError": "Unknown error"
303+
"unknownError": "Unknown error",
304+
"errorOccurredTryAgain": "An error occurred, please try again."
304305
}
305306
}

lib/locales/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
},
301301
"errors": {
302302
"errorOccurred": "Ocurrió un error",
303-
"unknownError": "Error desconocido"
303+
"unknownError": "Error desconocido",
304+
"errorOccurredTryAgain": "Ocurrió un error, por favor intenta de nuevo."
304305
}
305306
}

lib/locales/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
},
301301
"errors": {
302302
"errorOccurred": "Une erreur s'est produite",
303-
"unknownError": "Erreur inconnue"
303+
"unknownError": "Erreur inconnue",
304+
"errorOccurredTryAgain": "Une erreur s'est produite, veuillez réessayer."
304305
}
305306
}

lib/locales/it.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
},
301301
"errors": {
302302
"errorOccurred": "Si è verificato un errore",
303-
"unknownError": "Errore sconosciuto"
303+
"unknownError": "Errore sconosciuto",
304+
"errorOccurredTryAgain": "Si è verificato un errore, riprova per favore."
304305
}
305306
}

lib/locales/pt.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
},
301301
"errors": {
302302
"errorOccurred": "Ocorreu um erro",
303-
"unknownError": "Erro desconhecido"
303+
"unknownError": "Erro desconhecido",
304+
"errorOccurredTryAgain": "Ocorreu um erro, tente novamente por favor."
304305
}
305306
}

lib/locales/ru.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
},
301301
"errors": {
302302
"errorOccurred": "Произошла ошибка",
303-
"unknownError": "Неизвестная ошибка"
303+
"unknownError": "Неизвестная ошибка",
304+
"errorOccurredTryAgain": "Произошла ошибка, пожалуйста, попробуйте еще раз."
304305
}
305306
}

lib/locales/tr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
},
301301
"errors": {
302302
"errorOccurred": "Bir hata oluştu",
303-
"unknownError": "Bilinmeyen hata"
303+
"unknownError": "Bilinmeyen hata",
304+
"errorOccurredTryAgain": "Bir hata oluştu, lütfen tekrar deneyin."
304305
}
305306
}

lib/ui/contact_list/group_chat_details_sheet.dart

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:gap/gap.dart';
55
import 'package:go_router/go_router.dart';
66
import 'package:logging/logging.dart';
77
import 'package:whitenoise/config/providers/create_group_provider.dart';
8+
import 'package:whitenoise/config/states/create_group_state.dart';
89
import 'package:whitenoise/domain/models/contact_model.dart';
910
import 'package:whitenoise/routing/routes.dart';
1011
import 'package:whitenoise/src/rust/api/groups.dart';
@@ -53,7 +54,7 @@ class GroupChatDetailsSheet extends ConsumerStatefulWidget {
5354
class _GroupChatDetailsSheetState extends ConsumerState<GroupChatDetailsSheet> with SafeToastMixin {
5455
final TextEditingController _groupNameController = TextEditingController();
5556
final TextEditingController _groupDescriptionController = TextEditingController();
56-
57+
Group? createdGroup;
5758
@override
5859
void initState() {
5960
super.initState();
@@ -82,59 +83,70 @@ class _GroupChatDetailsSheetState extends ConsumerState<GroupChatDetailsSheet> w
8283
.createGroup(
8384
onGroupCreated: (createdGroup) {
8485
if (createdGroup != null && mounted) {
86+
this.createdGroup = createdGroup;
8587
context.pop();
86-
WidgetsBinding.instance.addPostFrameCallback(
87-
(_) async {
88-
if (mounted) {
89-
Routes.goToChat(context, createdGroup.mlsGroupId);
90-
}
91-
},
92-
);
9388
}
9489
},
9590
);
9691
}
9792

93+
void _showInviteSheet(CreateGroupState state) {
94+
WidgetsBinding.instance.addPostFrameCallback((_) async {
95+
if (mounted) {
96+
try {
97+
await ShareInviteBottomSheet.show(
98+
context: context,
99+
contacts: state.contactsWithoutKeyPackage,
100+
);
101+
} catch (e, st) {
102+
Logger('GroupChatDetailsSheet').severe('Error showing invite sheet', e, st);
103+
safeShowErrorToast('errors.errorOccurredTryAgain'.tr());
104+
} finally {
105+
ref.read(createGroupProvider.notifier).dismissInviteSheet();
106+
}
107+
}
108+
});
109+
}
110+
111+
void _goToChat() {
112+
if (createdGroup != null) {
113+
WidgetsBinding.instance.addPostFrameCallback(
114+
(_) async {
115+
if (mounted) {
116+
Routes.goToChat(context, createdGroup!.mlsGroupId);
117+
}
118+
},
119+
);
120+
}
121+
}
122+
98123
@override
99124
void dispose() {
100125
_groupNameController.removeListener(_onGroupNameChanged);
126+
_groupDescriptionController.removeListener(_onGroupDescriptionChanged);
127+
_groupDescriptionController.dispose();
101128
_groupNameController.dispose();
102129
super.dispose();
103130
}
104131

105132
@override
106133
Widget build(BuildContext context) {
107-
final state = ref.watch(createGroupProvider);
108-
109134
ref.listen(createGroupProvider, (previous, next) {
110135
if (next.error != null) {
111136
safeShowErrorToast(next.error!);
112137
ref.read(createGroupProvider.notifier).clearError();
113138
}
114-
115139
if (next.shouldShowInviteSheet && next.contactsWithoutKeyPackage.isNotEmpty) {
116-
WidgetsBinding.instance.addPostFrameCallback((_) async {
117-
if (mounted) {
118-
try {
119-
await ShareInviteBottomSheet.show(
120-
context: context,
121-
contacts: next.contactsWithoutKeyPackage,
122-
);
123-
} catch (e, st) {
124-
Logger('GroupChatDetailsSheet').severe('Error showing invite sheet', e, st);
125-
safeShowErrorToast('An error occurred, please try again.');
126-
} finally {
127-
ref.read(createGroupProvider.notifier).dismissInviteSheet();
128-
}
129-
}
130-
});
140+
_showInviteSheet(next);
131141
}
132142
});
133143

144+
final state = ref.watch(createGroupProvider);
134145
return PopScope(
135-
onPopInvokedWithResult: (didPop, result) {
146+
onPopInvokedWithResult: (didPop, _) {
136147
if (didPop) {
137148
ref.read(createGroupProvider.notifier).discardChanges();
149+
_goToChat();
138150
}
139151
},
140152
child: Column(

0 commit comments

Comments
 (0)