chore: Ask for storage persistence

This commit is contained in:
Krille 2023-05-23 15:21:38 +02:00
parent fa2ed930eb
commit 692d6042c5
No known key found for this signature in database
1 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:universal_html/html.dart' as html;
class FlutterHiveCollectionsDatabase extends HiveCollectionsDatabase { class FlutterHiveCollectionsDatabase extends HiveCollectionsDatabase {
FlutterHiveCollectionsDatabase( FlutterHiveCollectionsDatabase(
@ -29,7 +30,11 @@ class FlutterHiveCollectionsDatabase extends HiveCollectionsDatabase {
HiveAesCipher? hiverCipher; HiveAesCipher? hiverCipher;
try { try {
// Workaround for secure storage is calling Platform.operatingSystem on web // Workaround for secure storage is calling Platform.operatingSystem on web
if (kIsWeb) throw MissingPluginException(); if (kIsWeb) {
// ignore: unawaited_futures
html.window.navigator.storage?.persist();
throw MissingPluginException();
}
const secureStorage = FlutterSecureStorage(); const secureStorage = FlutterSecureStorage();
final containsEncryptionKey = final containsEncryptionKey =