mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 04:49:21 +00:00
Avoid app blocking
This commit is contained in:
parent
862401755d
commit
cc760c5a24
@ -3,6 +3,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:comunic/constants.dart';
|
||||
import 'package:comunic/utils/flutter_utils.dart';
|
||||
import 'package:comunic/utils/log_utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
@ -54,7 +55,8 @@ abstract class BaseSerializationHelper<T extends SerializableElement> {
|
||||
|
||||
_cache.sort();
|
||||
} catch (e, s) {
|
||||
print("Failed to read serialized data! $e => $s");
|
||||
logError(e, s);
|
||||
print("Failed to read serialized data!");
|
||||
_cache = [];
|
||||
}
|
||||
}
|
||||
@ -63,9 +65,14 @@ abstract class BaseSerializationHelper<T extends SerializableElement> {
|
||||
Future<void> _saveCache() async {
|
||||
if (isWeb) return;
|
||||
|
||||
final file = await _getFilePath();
|
||||
await file.writeAsString(jsonEncode(
|
||||
_cache.map((e) => e.toJson()).toList().cast<Map<String, dynamic>>()));
|
||||
try {
|
||||
final file = await _getFilePath();
|
||||
await file.writeAsString(jsonEncode(
|
||||
_cache.map((e) => e.toJson()).toList().cast<Map<String, dynamic>>()));
|
||||
} catch (e, s) {
|
||||
print("Failed to write file!");
|
||||
logError(e, s);
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the current list of elements
|
||||
|
Loading…
Reference in New Issue
Block a user