mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Automatically cleanup user information
This commit is contained in:
parent
d822e0edd8
commit
03c4a4eae0
@ -1,4 +1,5 @@
|
|||||||
import 'package:comunic/helpers/database/database_contract.dart';
|
import 'package:comunic/helpers/database/database_contract.dart';
|
||||||
|
import 'package:connectivity/connectivity.dart';
|
||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
|
||||||
@ -29,6 +30,13 @@ abstract class DatabaseHelper {
|
|||||||
return _db;
|
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
|
/// Perform database update
|
||||||
///
|
///
|
||||||
/// Currently : delete all the database tables and initialize it again
|
/// 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 TABLE IF EXISTS ${ConversationsMessagesTableContract.TABLE_NAME}");
|
||||||
|
|
||||||
// Drop friends list table
|
// Drop friends list table
|
||||||
await db.execute(
|
await db
|
||||||
"DROP TABLE IF EXISTS ${FriendsListTableContract.TABLE_NAME}");
|
.execute("DROP TABLE IF EXISTS ${FriendsListTableContract.TABLE_NAME}");
|
||||||
|
|
||||||
// Initialize database again
|
// Initialize database again
|
||||||
await _initializeDatabase(db, newVersion);
|
await _initializeDatabase(db, newVersion);
|
||||||
|
@ -12,11 +12,11 @@ import 'package:flutter/material.dart';
|
|||||||
/// @author Pierre HUBERT
|
/// @author Pierre HUBERT
|
||||||
|
|
||||||
void subMain() async {
|
void subMain() async {
|
||||||
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
// Connect to database
|
// Connect to database
|
||||||
await DatabaseHelper.open();
|
await DatabaseHelper.open();
|
||||||
|
await DatabaseHelper.cleanUpDatabase();
|
||||||
|
|
||||||
// Get current system language
|
// Get current system language
|
||||||
await initTranslations();
|
await initTranslations();
|
||||||
|
39
pubspec.lock
39
pubspec.lock
@ -50,6 +50,27 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.14.11"
|
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:
|
convert:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -197,7 +218,21 @@ packages:
|
|||||||
name: path_provider
|
name: path_provider
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
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:
|
pedantic:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -415,4 +450,4 @@ packages:
|
|||||||
version: "3.5.0"
|
version: "3.5.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.7.0 <3.0.0"
|
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
|
# Display zoomable images
|
||||||
photo_view: ^0.9.2
|
photo_view: ^0.9.2
|
||||||
|
|
||||||
|
# Check Internet connection
|
||||||
|
connectivity: ^0.4.8+2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
Loading…
Reference in New Issue
Block a user