Sincronizar dados remotos com as opções do sistema
This commit is contained in:
parent
d2e12b31f4
commit
926944b178
|
@ -37,9 +37,11 @@ class LocalsLocalDataSourceImpl implements LocalsLocalDataSource {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> set<T>(String key, T value) async {
|
Future<void> set<T>(String key, T value) async {
|
||||||
|
try {
|
||||||
var date = DateTime.now().toIso8601String();
|
var date = DateTime.now().toIso8601String();
|
||||||
final String? local =
|
final String? local =
|
||||||
await StorageHelper().get(ProfileStorageKey.clientUUID.key);
|
await StorageHelper().get(ProfileStorageKey.clientUUID.key);
|
||||||
|
|
||||||
await DatabaseService.database.insert(
|
await DatabaseService.database.insert(
|
||||||
LocalsConstants.tableLocalsKeychain,
|
LocalsConstants.tableLocalsKeychain,
|
||||||
{
|
{
|
||||||
|
@ -49,9 +51,11 @@ class LocalsLocalDataSourceImpl implements LocalsLocalDataSource {
|
||||||
'updateAt': date,
|
'updateAt': date,
|
||||||
'resolvedAt': date,
|
'resolvedAt': date,
|
||||||
'createdAt': date,
|
'createdAt': date,
|
||||||
'locals': local
|
'local': local
|
||||||
},
|
},
|
||||||
conflictAlgorithm: ConflictAlgorithm.replace);
|
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||||
|
);
|
||||||
|
} catch (e, s) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -8,7 +8,6 @@ import 'package:hub/features/local/index.dart';
|
||||||
|
|
||||||
import 'package:hub/shared/utils/dialog_util.dart';
|
import 'package:hub/shared/utils/dialog_util.dart';
|
||||||
import 'package:hub/shared/utils/log_util.dart';
|
import 'package:hub/shared/utils/log_util.dart';
|
||||||
import 'package:hub/shared/extensions/index.dart';
|
|
||||||
|
|
||||||
class LocalUtil {
|
class LocalUtil {
|
||||||
static void handleError(BuildContext context, String errorMsg) async {
|
static void handleError(BuildContext context, String errorMsg) async {
|
||||||
|
@ -121,14 +120,14 @@ class LocalUtil {
|
||||||
jsonBody['visitado']['VDO_NOTTERCEIROS'],
|
jsonBody['visitado']['VDO_NOTTERCEIROS'],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (jsonBody['visitado']['VDO_SENHA'] == '') {
|
if (jsonBody['visitado']['VDO_TEM_SENHA_ACESSO'] == '') {
|
||||||
await StorageHelper().set(
|
await StorageHelper().set(
|
||||||
LocalsStorageKey.access.key,
|
LocalsStorageKey.access.key,
|
||||||
_processSystemOption(jsonBody['visitado']['VDO_SENHA']),
|
_processSystemOption(jsonBody['visitado']['VDO_TEM_SENHA_ACESSO']),
|
||||||
);
|
);
|
||||||
await StorageHelper().set(
|
await StorageHelper().set(
|
||||||
LocalsStorageKey.panic.key,
|
LocalsStorageKey.panic.key,
|
||||||
_processSystemOption(jsonBody['visitado']['VDO_SENHA_PANICO']),
|
_processSystemOption(jsonBody['visitado']['VDO_TEM_SENHA_PANICO']),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@ class LocalsConstants {
|
||||||
updateAt TEXT,
|
updateAt TEXT,
|
||||||
resolvedAt TEXT,
|
resolvedAt TEXT,
|
||||||
createdAt TEXT,
|
createdAt TEXT,
|
||||||
local TEXT
|
local TEXT,
|
||||||
|
UNIQUE (key, local)
|
||||||
);
|
);
|
||||||
''';
|
''';
|
||||||
static String get deleteLocalsTable =>
|
static String get deleteLocalsTable =>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import 'package:hub/features/module/index.dart';
|
import 'package:hub/features/module/index.dart';
|
||||||
import 'package:hub/features/storage/index.dart';
|
import 'package:hub/features/storage/index.dart';
|
||||||
import 'package:hub/shared/constants/index.dart';
|
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
|
|
||||||
|
@ -57,6 +56,7 @@ class DatabaseService {
|
||||||
Database database, int oldVersion, int newVersion) async {
|
Database database, int oldVersion, int newVersion) async {
|
||||||
print('Upgrading database from version $oldVersion to $newVersion...');
|
print('Upgrading database from version $oldVersion to $newVersion...');
|
||||||
if (oldVersion < 2 && newVersion >= 2) {
|
if (oldVersion < 2 && newVersion >= 2) {
|
||||||
|
await database.execute(LicenseConstants.createLicenseTable);
|
||||||
await database.execute(LicenseConstants.updatePetsHistoryTrigger);
|
await database.execute(LicenseConstants.updatePetsHistoryTrigger);
|
||||||
await database.execute(LicenseConstants.updateDisplayTrigger);
|
await database.execute(LicenseConstants.updateDisplayTrigger);
|
||||||
await database.execute(LicenseConstants.insertDisplayTrigger);
|
await database.execute(LicenseConstants.insertDisplayTrigger);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// ignore_for_file: constant_identifier_names
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
|
@ -24,6 +24,9 @@ class PreferencesPageModel with ChangeNotifier {
|
||||||
late bool isPanic = false;
|
late bool isPanic = false;
|
||||||
|
|
||||||
Future<void> _initialize() async {
|
Future<void> _initialize() async {
|
||||||
|
log(
|
||||||
|
'TESTE:' + '${await StorageHelper().get(LocalsStorageKey.notify.key)}',
|
||||||
|
);
|
||||||
isFingerprint =
|
isFingerprint =
|
||||||
await StorageHelper().get(LocalsStorageKey.fingerprint.key) == 'true';
|
await StorageHelper().get(LocalsStorageKey.fingerprint.key) == 'true';
|
||||||
isPerson = await StorageHelper().get(LocalsStorageKey.person.key) == 'true';
|
isPerson = await StorageHelper().get(LocalsStorageKey.person.key) == 'true';
|
||||||
|
@ -66,8 +69,7 @@ class PreferencesPageModel with ChangeNotifier {
|
||||||
.call(notifica: value)
|
.call(notifica: value)
|
||||||
.then((value) async {
|
.then((value) async {
|
||||||
if (value.jsonBody['error'] == false) {
|
if (value.jsonBody['error'] == false) {
|
||||||
await StorageHelper().set(
|
await StorageHelper().set(LocalsStorageKey.notify.key, !isNotify);
|
||||||
LocalsStorageKey.notify.key, isNotify ? 'false' : 'true');
|
|
||||||
content = FFLocalizations.of(context).getVariableText(
|
content = FFLocalizations.of(context).getVariableText(
|
||||||
enText: 'Notification changed successfully',
|
enText: 'Notification changed successfully',
|
||||||
ptText: 'Notificação alterada com sucesso',
|
ptText: 'Notificação alterada com sucesso',
|
||||||
|
@ -147,8 +149,8 @@ class PreferencesPageModel with ChangeNotifier {
|
||||||
.then((value) async {
|
.then((value) async {
|
||||||
final String content;
|
final String content;
|
||||||
if (jsonDecode(value.jsonBody['error'].toString()) == false) {
|
if (jsonDecode(value.jsonBody['error'].toString()) == false) {
|
||||||
await StorageHelper().set(
|
await StorageHelper()
|
||||||
LocalsStorageKey.access.key, isAccess ? 'false' : 'true');
|
.set(LocalsStorageKey.access.key, isAccess ? false : true);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
content = FFLocalizations.of(context).getVariableText(
|
content = FFLocalizations.of(context).getVariableText(
|
||||||
enText: 'Access pass changed successfully',
|
enText: 'Access pass changed successfully',
|
||||||
|
|
Loading…
Reference in New Issue