From 6e4c2ca7fee33e743829366a0892c62afce5d38a Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Wed, 15 Jan 2025 09:52:39 -0300 Subject: [PATCH 1/2] =?UTF-8?q?fix=20setupLicense=20quando=20api=20nova=20?= =?UTF-8?q?com=20modulariza=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/features/auth/authentication_service.dart | 6 +++--- .../data/repositories/license_repository_impl.dart | 1 + .../storage/helpers/dabase_storage_helper.dart | 11 +++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/features/auth/authentication_service.dart b/lib/features/auth/authentication_service.dart index 12393545..557b05ba 100644 --- a/lib/features/auth/authentication_service.dart +++ b/lib/features/auth/authentication_service.dart @@ -1,14 +1,14 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:hub/features/backend/index.dart'; import 'package:hub/features/local/index.dart'; import 'package:hub/features/module/data/repositories/license_repository_impl.dart'; import 'package:hub/features/storage/index.dart'; - import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/shared/utils/device_util.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/log_util.dart'; - import 'package:hub/shared/utils/snackbar_util.dart'; import '../../../flutter_flow/flutter_flow_util.dart'; @@ -140,6 +140,7 @@ class AuthenticationService { } static Future signOut(BuildContext context) async { + log('Sign Out'); await PhpGroup.unregisterDevice.call(); final Map extra = { kTransitionInfoKey: const TransitionInfo( @@ -151,7 +152,6 @@ class AuthenticationService { await StorageHelper().clean(Storage.databaseStorage); await StorageHelper().clean(Storage.secureStorage); - await LicenseRepositoryImpl().cleanLicense(); DatabaseService.isInitialized = false; await DatabaseService.instance.init(); diff --git a/lib/features/module/data/repositories/license_repository_impl.dart b/lib/features/module/data/repositories/license_repository_impl.dart index 087de1a5..643f6473 100644 --- a/lib/features/module/data/repositories/license_repository_impl.dart +++ b/lib/features/module/data/repositories/license_repository_impl.dart @@ -21,6 +21,7 @@ class LicenseRepositoryImpl implements LicenseRepository { bool result = false; final bool isNewVersion = await localDataSource.isNewVersion(); if (isNewVersion) { + await remoteDataSource.setupLicense(database, isNewVersion); result = await remoteDataSource.fetchLicenses(isNewVersion); } else { result = await remoteDataSource.setupLicense(database, isNewVersion); diff --git a/lib/features/storage/helpers/dabase_storage_helper.dart b/lib/features/storage/helpers/dabase_storage_helper.dart index 63839577..7bf0ba2c 100644 --- a/lib/features/storage/helpers/dabase_storage_helper.dart +++ b/lib/features/storage/helpers/dabase_storage_helper.dart @@ -4,6 +4,7 @@ import 'package:hub/features/storage/index.dart'; class DatabaseStorage implements BaseStorage { DatabaseStorage._(); + static final DatabaseStorage instance = DatabaseStorage._(); // static final DatabaseStorage instance = DatabaseStorage._(); @@ -22,17 +23,23 @@ class DatabaseStorage implements BaseStorage { } @override - Future clearAll() => // - throw UnimplementedError(); + Future clearAll() async { + await ProfileLocalDataSourceImpl().clearAll(); + await LocalsLocalDataSourceImpl().clearAll(); + } + @override Future delete(String key) async => await getInstanceByKey(key).delete(key); + @override Future get(String key) async => // await getInstanceByKey(key).get(key); + @override Future init() async => // await DatabaseService.instance.init(); + @override Future set(String key, T value) async => await getInstanceByKey(key).set(key, value); From 05d98044884642ea4d6faebe329358f291aea379 Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Wed, 15 Jan 2025 10:09:18 -0300 Subject: [PATCH 2/2] remove logs --- lib/features/auth/authentication_service.dart | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/features/auth/authentication_service.dart b/lib/features/auth/authentication_service.dart index 557b05ba..d8ce20ae 100644 --- a/lib/features/auth/authentication_service.dart +++ b/lib/features/auth/authentication_service.dart @@ -1,9 +1,6 @@ -import 'dart:developer'; - import 'package:flutter/material.dart'; import 'package:hub/features/backend/index.dart'; import 'package:hub/features/local/index.dart'; -import 'package:hub/features/module/data/repositories/license_repository_impl.dart'; import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/shared/utils/device_util.dart'; @@ -140,7 +137,6 @@ class AuthenticationService { } static Future signOut(BuildContext context) async { - log('Sign Out'); await PhpGroup.unregisterDevice.call(); final Map extra = { kTransitionInfoKey: const TransitionInfo(