mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Automatically cleanup user information
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
import 'package:comunic/helpers/database/database_contract.dart';
 | 
			
		||||
import 'package:connectivity/connectivity.dart';
 | 
			
		||||
import 'package:path/path.dart';
 | 
			
		||||
import 'package:sqflite/sqflite.dart';
 | 
			
		||||
 | 
			
		||||
@@ -29,6 +30,13 @@ abstract class DatabaseHelper {
 | 
			
		||||
    return _db;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// Cleanup database
 | 
			
		||||
  static Future<void> cleanUpDatabase() async {
 | 
			
		||||
    // If connected to a network, cleanup user information
 | 
			
		||||
    if (await Connectivity().checkConnectivity() != ConnectivityResult.none)
 | 
			
		||||
      await _db.execute("DELETE FROM ${UserTableContract.TABLE_NAME}");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// Perform database update
 | 
			
		||||
  ///
 | 
			
		||||
  /// Currently : delete all the database tables and initialize it again
 | 
			
		||||
@@ -46,8 +54,8 @@ abstract class DatabaseHelper {
 | 
			
		||||
        "DROP TABLE IF EXISTS ${ConversationsMessagesTableContract.TABLE_NAME}");
 | 
			
		||||
 | 
			
		||||
    // Drop friends list table
 | 
			
		||||
    await db.execute(
 | 
			
		||||
        "DROP TABLE IF EXISTS ${FriendsListTableContract.TABLE_NAME}");
 | 
			
		||||
    await db
 | 
			
		||||
        .execute("DROP TABLE IF EXISTS ${FriendsListTableContract.TABLE_NAME}");
 | 
			
		||||
 | 
			
		||||
    // Initialize database again
 | 
			
		||||
    await _initializeDatabase(db, newVersion);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user