Refactor
This commit is contained in:
parent
a6078af25a
commit
fe94e3886a
|
|
@ -1,3 +1,4 @@
|
|||
const String kAppVersion = 'v0.0.1';
|
||||
|
||||
const int kMillisecondsToRefreshData = 1000 * 60 * 10;
|
||||
const String kStateFilename = 'state';
|
||||
const int kMillisecondsToRefreshData = 1000 * 60 * 10;
|
||||
|
|
@ -9,11 +9,9 @@ import 'package:invoiceninja/data/file_storage.dart';
|
|||
import 'package:invoiceninja/data/web_client.dart';
|
||||
|
||||
class AuthRepository {
|
||||
final FileStorage fileStorage;
|
||||
final WebClient webClient;
|
||||
|
||||
const AuthRepository({
|
||||
@required this.fileStorage,
|
||||
this.webClient = const WebClient(),
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,9 @@ import 'package:invoiceninja/data/file_storage.dart';
|
|||
import 'package:invoiceninja/data/web_client.dart';
|
||||
|
||||
class DashboardRepository {
|
||||
final FileStorage fileStorage;
|
||||
final WebClient webClient;
|
||||
|
||||
const DashboardRepository({
|
||||
@required this.fileStorage,
|
||||
this.webClient = const WebClient(),
|
||||
});
|
||||
|
||||
|
|
@ -21,24 +19,9 @@ class DashboardRepository {
|
|||
final response = await webClient.get(
|
||||
auth.url + '/dashboard', company.token);
|
||||
|
||||
//fileStorage.saveDashboard(products);
|
||||
|
||||
DashboardResponse dashboardResponse = serializers.deserializeWith(
|
||||
DashboardResponse.serializer, response);
|
||||
|
||||
return dashboardResponse.data;
|
||||
|
||||
/*
|
||||
try {
|
||||
return await fileStorage.loadData();
|
||||
} catch (exception) {
|
||||
final products = await webClient.fetchData(
|
||||
auth.url + '/products', auth.token);
|
||||
|
||||
//fileStorage.saveDashboard(products);
|
||||
|
||||
return products;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
@ -11,11 +11,9 @@ import 'package:invoiceninja/data/file_storage.dart';
|
|||
import 'package:invoiceninja/data/web_client.dart';
|
||||
|
||||
class ProductsRepository {
|
||||
final FileStorage fileStorage;
|
||||
final WebClient webClient;
|
||||
|
||||
const ProductsRepository({
|
||||
@required this.fileStorage,
|
||||
this.webClient = const WebClient(),
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:invoiceninja/constants.dart';
|
||||
import 'package:invoiceninja/data/file_storage.dart';
|
||||
import 'package:invoiceninja/data/repositories/persistence_repository.dart';
|
||||
import 'package:invoiceninja/redux/app/app_state.dart';
|
||||
|
|
@ -12,7 +13,7 @@ import 'package:path_provider/path_provider.dart';
|
|||
List<Middleware<AppState>> createStorePersistenceMiddleware([
|
||||
PersistenceRepository repository = const PersistenceRepository(
|
||||
fileStorage: const FileStorage(
|
||||
'state',
|
||||
kStateFilename,
|
||||
getApplicationDocumentsDirectory,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -8,12 +8,7 @@ import 'package:path_provider/path_provider.dart';
|
|||
import 'package:invoiceninja/redux/company/company_actions.dart';
|
||||
|
||||
List<Middleware<AppState>> createStoreAuthMiddleware([
|
||||
AuthRepository repository = const AuthRepository(
|
||||
fileStorage: const FileStorage(
|
||||
'__invoiceninja__',
|
||||
getApplicationDocumentsDirectory,
|
||||
),
|
||||
),
|
||||
AuthRepository repository = const AuthRepository(),
|
||||
]) {
|
||||
final loginInit = _createLoginInit();
|
||||
final loginRequest = _createLoginRequest(repository);
|
||||
|
|
|
|||
|
|
@ -6,12 +6,7 @@ import 'package:invoiceninja/data/repositories/dashboard_repository.dart';
|
|||
import 'package:invoiceninja/data/file_storage.dart';
|
||||
|
||||
List<Middleware<AppState>> createStoreDashboardMiddleware([
|
||||
DashboardRepository repository = const DashboardRepository(
|
||||
fileStorage: const FileStorage(
|
||||
'__invoiceninja__',
|
||||
getApplicationDocumentsDirectory,
|
||||
),
|
||||
),
|
||||
DashboardRepository repository = const DashboardRepository(),
|
||||
]) {
|
||||
final loadDashboard = _createLoadDashboard(repository);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,7 @@ import 'package:invoiceninja/data/repositories/product_repository.dart';
|
|||
import 'package:invoiceninja/data/file_storage.dart';
|
||||
|
||||
List<Middleware<AppState>> createStoreProductsMiddleware([
|
||||
ProductsRepository repository = const ProductsRepository(
|
||||
fileStorage: const FileStorage(
|
||||
'__invoiceninja__',
|
||||
getApplicationDocumentsDirectory,
|
||||
),
|
||||
),
|
||||
ProductsRepository repository = const ProductsRepository(),
|
||||
]) {
|
||||
final loadProducts = _loadProducts(repository);
|
||||
final saveProduct = _saveProduct(repository);
|
||||
|
|
|
|||
Loading…
Reference in New Issue