fix: in recording dialog, throw exception on permission denied (#5114)
This commit is contained in:
parent
4112fd2a37
commit
9efc40af31
1 changed files with 11 additions and 10 deletions
|
|
@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:path/path.dart' as path_lib;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:record/record.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
|
|
@ -18,6 +17,8 @@ import 'package:fluffychat/utils/platform_infos.dart';
|
|||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'events/audio_player.dart';
|
||||
|
||||
class PermissionException implements Exception {}
|
||||
|
||||
class RecordingDialog extends StatefulWidget {
|
||||
const RecordingDialog({
|
||||
super.key,
|
||||
|
|
@ -63,14 +64,14 @@ class RecordingDialogState extends State<RecordingDialog> {
|
|||
path = path_lib.join(tempDir.path, fileName);
|
||||
}
|
||||
|
||||
// #Pangea
|
||||
await _audioRecorder.hasPermission();
|
||||
// final result = await _audioRecorder.hasPermission();
|
||||
// if (result != true) {
|
||||
// setState(() => error = true);
|
||||
// return;
|
||||
// }
|
||||
// Pangea#
|
||||
final result = await _audioRecorder.hasPermission();
|
||||
if (result != true) {
|
||||
// #Pangea
|
||||
throw PermissionException();
|
||||
// setState(() => error = true);
|
||||
// return;
|
||||
// Pangea#
|
||||
}
|
||||
await WakelockPlus.enable();
|
||||
|
||||
await _audioRecorder.start(
|
||||
|
|
@ -158,7 +159,7 @@ class RecordingDialogState extends State<RecordingDialog> {
|
|||
final content = error != null
|
||||
? ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 250.0),
|
||||
child: error is html.DomException
|
||||
child: error is PermissionException
|
||||
? Text(L10n.of(context).recordingPermissionDenied)
|
||||
: kIsWeb
|
||||
? Text(L10n.of(context).genericWebRecordingError)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue