chore: Better error handling for recording viewmodel
This commit is contained in:
parent
422e94ab45
commit
975ba31b4d
1 changed files with 13 additions and 6 deletions
|
|
@ -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…
Add table
Reference in a new issue