diff --git a/lib/pages/chat/recording_view_model.dart b/lib/pages/chat/recording_view_model.dart index 4c3471008..ae5ca637f 100644 --- a/lib/pages/chat/recording_view_model.dart +++ b/lib/pages/chat/recording_view_model.dart @@ -33,7 +33,6 @@ class RecordingViewModelState extends State { Timer? _recorderSubscription; Duration duration = Duration.zero; - bool error = false; bool isSending = false; bool get isRecording => _audioRecorder != null; @@ -83,7 +82,11 @@ class RecordingViewModelState extends State { final result = await audioRecorder.hasPermission(); if (result != true) { - setState(() => error = true); + showOkAlertDialog( + context: context, + title: L10n.of(context).oopsSomethingWentWrong, + message: L10n.of(context).noPermission, + ); return; } await WakelockPlus.enable(); @@ -102,9 +105,14 @@ class RecordingViewModelState extends State { ); setState(() => duration = Duration.zero); _subscribe(); - } catch (_) { - setState(() => error = true); - rethrow; + } catch (e, s) { + Logs().w('Unable to start voice message recording', e, s); + showOkAlertDialog( + context: context, + title: L10n.of(context).oopsSomethingWentWrong, + message: e.toString(), + ); + setState(_reset); } } @@ -134,7 +142,6 @@ class RecordingViewModelState extends State { _audioRecorder?.stop(); _audioRecorder = null; isSending = false; - error = false; fileName = null; duration = Duration.zero; amplitudeTimeline.clear();