mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 12:14:11 +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/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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user