diff --git a/lib/data/network/dio_cache_option.dart b/lib/data/network/dio_cache_option.dart index f167c15240..fbb83c6215 100644 --- a/lib/data/network/dio_cache_option.dart +++ b/lib/data/network/dio_cache_option.dart @@ -1,8 +1,6 @@ import 'package:dio_cache_interceptor/dio_cache_interceptor.dart'; import 'package:dio_cache_interceptor_hive_store/dio_cache_interceptor_hive_store.dart'; -import 'package:flutter/foundation.dart'; import 'package:matrix/matrix.dart'; -import 'package:path_provider/path_provider.dart'; class DioCacheOption { static const String _hiveBoxName = "twake_dio_cache_hive_store"; @@ -20,18 +18,10 @@ class DioCacheOption { return _instance; } - Future _getAppDirPath() async { - if (kIsWeb) return null; - final appDir = await getApplicationDocumentsDirectory(); - Logs().d('DioCacheOption::_getAppDirPath() appDirPath ${appDir.path}'); - return appDir.path; - } - Future setUpDioHiveCache() async { Logs().d('DioCacheOption::_setUpDioHiveCache() Start setup DioHiveCache'); - final appDirPath = await _getAppDirPath(); _hiveCacheStore = HiveCacheStore( - appDirPath, + null, hiveBoxName: _hiveBoxName, ); Logs().d('DioCacheOption::_setUpDioHiveCache() DioHiveCache Ready'); diff --git a/lib/di/global/get_it_initializer.dart b/lib/di/global/get_it_initializer.dart index a1f9652ab5..8deeb4c4fc 100644 --- a/lib/di/global/get_it_initializer.dart +++ b/lib/di/global/get_it_initializer.dart @@ -9,6 +9,7 @@ import 'package:fluffychat/data/datasource_impl/media/media_data_source_impl.dar import 'package:fluffychat/data/datasource_impl/recovery_words_data_source_impl.dart'; import 'package:fluffychat/data/datasource_impl/tom_configurations_datasource_impl.dart'; import 'package:fluffychat/data/network/contact/tom_contact_api.dart'; +import 'package:fluffychat/data/network/dio_cache_option.dart'; import 'package:fluffychat/data/network/media/media_api.dart'; import 'package:fluffychat/data/network/recovery_words/recovery_words_api.dart'; import 'package:fluffychat/data/repository/contact/tom_contact_repository_impl.dart'; @@ -65,6 +66,7 @@ class GetItInitializer { } void bindingGlobal() { + setupDioCache(); NetworkDI().bind(); HiveDI().bind(); NetworkConnectivityDI().bind(); @@ -75,6 +77,10 @@ class GetItInitializer { getIt.registerFactory(() => Queue()); } + void setupDioCache() { + DioCacheOption.instance.setUpDioHiveCache(); + } + void bindingAPI() { getIt.registerLazySingleton(() => RecoveryWordsAPI()); getIt.registerFactory(() => TomContactAPI()); diff --git a/lib/main.dart b/lib/main.dart index 38d2e37274..3f37b52355 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,6 @@ import 'package:collection/collection.dart'; import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/config/setting_keys.dart'; -import 'package:fluffychat/data/network/dio_cache_option.dart'; import 'package:fluffychat/di/global/get_it_initializer.dart'; import 'package:fluffychat/utils/client_manager.dart'; import 'package:fluffychat/utils/platform_infos.dart'; @@ -30,8 +29,6 @@ void main() async { await firstClient?.roomsLoading; await firstClient?.accountDataLoading; - await DioCacheOption.instance.setUpDioHiveCache(); - GetItInitializer().setUp(); // If the app starts in detached mode, we assume that it is in