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