mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 12:14:11 +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);
 | 
			
		||||
 
 | 
			
		||||
@@ -12,11 +12,11 @@ import 'package:flutter/material.dart';
 | 
			
		||||
/// @author Pierre HUBERT
 | 
			
		||||
 | 
			
		||||
void subMain() async {
 | 
			
		||||
 | 
			
		||||
  WidgetsFlutterBinding.ensureInitialized();
 | 
			
		||||
 | 
			
		||||
  // Connect to database
 | 
			
		||||
  await DatabaseHelper.open();
 | 
			
		||||
  await DatabaseHelper.cleanUpDatabase();
 | 
			
		||||
 | 
			
		||||
  // Get current system language
 | 
			
		||||
  await initTranslations();
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										39
									
								
								pubspec.lock
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								pubspec.lock
									
									
									
									
									
								
							@@ -50,6 +50,27 @@ packages:
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "1.14.11"
 | 
			
		||||
  connectivity:
 | 
			
		||||
    dependency: "direct main"
 | 
			
		||||
    description:
 | 
			
		||||
      name: connectivity
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "0.4.8+2"
 | 
			
		||||
  connectivity_macos:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
      name: connectivity_macos
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "0.1.0+2"
 | 
			
		||||
  connectivity_platform_interface:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
      name: connectivity_platform_interface
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "1.0.3"
 | 
			
		||||
  convert:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
@@ -197,7 +218,21 @@ packages:
 | 
			
		||||
      name: path_provider
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "1.6.1"
 | 
			
		||||
    version: "1.6.5"
 | 
			
		||||
  path_provider_macos:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
      name: path_provider_macos
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "0.0.4"
 | 
			
		||||
  path_provider_platform_interface:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
      name: path_provider_platform_interface
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "1.0.1"
 | 
			
		||||
  pedantic:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
@@ -415,4 +450,4 @@ packages:
 | 
			
		||||
    version: "3.5.0"
 | 
			
		||||
sdks:
 | 
			
		||||
  dart: ">=2.7.0 <3.0.0"
 | 
			
		||||
  flutter: ">=1.12.13+hotfix.4 <2.0.0"
 | 
			
		||||
  flutter: ">=1.12.13+hotfix.5 <2.0.0"
 | 
			
		||||
 
 | 
			
		||||
@@ -66,6 +66,9 @@ dependencies:
 | 
			
		||||
  # Display zoomable images
 | 
			
		||||
  photo_view: ^0.9.2
 | 
			
		||||
 | 
			
		||||
  # Check Internet connection
 | 
			
		||||
  connectivity: ^0.4.8+2
 | 
			
		||||
 | 
			
		||||
dev_dependencies:
 | 
			
		||||
  flutter_test:
 | 
			
		||||
    sdk: flutter
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user