chore: Better error handling for recording viewmodel

pull/2295/head
Christian Kußowski 7 days ago
parent 422e94ab45
commit 975ba31b4d
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -33,7 +33,6 @@ class RecordingViewModelState extends State<RecordingViewModel> {
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<RecordingViewModel> {
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<RecordingViewModel> {
);
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<RecordingViewModel> {
_audioRecorder?.stop();
_audioRecorder = null;
isSending = false;
error = false;
fileName = null;
duration = Duration.zero;
amplitudeTimeline.clear();

Loading…
Cancel
Save