fixed client-reported crashes in the pdf viewer, image picker and prosemirror images, mapped webdav errors to user messages and hardened keychain, cache and push stores against io failures
This commit is contained in:
1 parent
c5592f117b
commit
23e4510bf8
19 files changed
+545
-55
No files matched your search
@@ -53,13 +53,21 @@ class FilePick {
|
||||
return result?.files.map((e) => e.path).nonNulls.toList();
|
||||
}
|
||||
|
||||
static bool _inFlight = false;
|
||||
|
||||
/// A second tap while the native picker is already open (double tap, or a
|
||||
/// tap on another source tile) would make the plugin throw instead of
|
||||
/// opening a second picker; it is treated as a cancel.
|
||||
static Future<T?> _guarded<T>(
|
||||
BuildContext context,
|
||||
Future<T?> Function() pick,
|
||||
) async {
|
||||
if (_inFlight) return null;
|
||||
_inFlight = true;
|
||||
try {
|
||||
return await pick();
|
||||
} on PlatformException catch (e) {
|
||||
if (_isAlreadyActive(e)) return null;
|
||||
final denied = PermissionException.fromPlatform(e);
|
||||
if (!context.mounted) return null;
|
||||
if (denied != null) {
|
||||
@@ -71,9 +79,15 @@ class FilePick {
|
||||
} catch (e) {
|
||||
if (context.mounted) _showErrorDialog(context, e);
|
||||
return null;
|
||||
} finally {
|
||||
_inFlight = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Android reports `already_active`, iOS `multiple_request`.
|
||||
static bool _isAlreadyActive(PlatformException e) =>
|
||||
e.code == 'already_active' || e.code == 'multiple_request';
|
||||
|
||||
static void _showPermissionDialog(
|
||||
BuildContext context,
|
||||
PermissionException denied,
|
||||
|
||||
Reference in new issue
Block a user