Bug fixes

This commit is contained in:
Hillel Coren 2018-09-16 21:15:43 +03:00
parent 1c561aa36d
commit 155a4f4c64
11 changed files with 15 additions and 19 deletions

View File

@ -35,10 +35,10 @@ class ClientRepository {
Future<BuiltList<ClientEntity>> loadList(CompanyEntity company, AuthState auth, int updatedAt) async { Future<BuiltList<ClientEntity>> loadList(CompanyEntity company, AuthState auth, int updatedAt) async {
String url = auth.url + '/clients'; String url = auth.url + '/clients?';
if (updatedAt > 0) { if (updatedAt > 0) {
url += '?updated_at=${updatedAt - kUpdatedAtBufferSeconds}'; url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
} }
final dynamic response = await webClient.get(url, company.token); final dynamic response = await webClient.get(url, company.token);

View File

@ -18,7 +18,7 @@ class PaymentRepository {
Future<BuiltList<PaymentEntity>> loadList( Future<BuiltList<PaymentEntity>> loadList(
CompanyEntity company, AuthState auth, int updatedAt) async { CompanyEntity company, AuthState auth, int updatedAt) async {
String url = auth.url + '/payments'; String url = auth.url + '/payments?';
if (updatedAt > 0) { if (updatedAt > 0) {
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}'; url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';

View File

@ -18,10 +18,10 @@ class ProductRepository {
Future<BuiltList<ProductEntity>> loadList(CompanyEntity company, AuthState auth, int updatedAt) async { Future<BuiltList<ProductEntity>> loadList(CompanyEntity company, AuthState auth, int updatedAt) async {
String url = auth.url + '/products'; String url = auth.url + '/products?';
if (updatedAt > 0) { if (updatedAt > 0) {
url += '?updated_at=${updatedAt - kUpdatedAtBufferSeconds}'; url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
} }
final dynamic response = await webClient.get(url, company.token); final dynamic response = await webClient.get(url, company.token);

View File

@ -44,9 +44,10 @@ class WebClient {
}, },
); );
print('url: $url');
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
print('==== FAILED ===='); print('==== FAILED ====');
print('url: $url');
print('body: ${response.body}'); print('body: ${response.body}');
throw _parseError(response.body); throw _parseError(response.body);

View File

@ -213,8 +213,7 @@ Middleware<AppState> _loadClients(ClientRepository repository) {
return; return;
} }
final int updatedAt = final int updatedAt = (state.clientState.lastUpdated / 1000).round();
action.force ? 0 : (state.clientState.lastUpdated / 1000).round();
store.dispatch(LoadClientsRequest()); store.dispatch(LoadClientsRequest());
repository repository

View File

@ -277,8 +277,7 @@ Middleware<AppState> _loadInvoices(InvoiceRepository repository) {
return; return;
} }
final int updatedAt = final int updatedAt = (state.clientState.lastUpdated / 1000).round();
action.force ? 0 : (state.invoiceState.lastUpdated / 1000).round();
store.dispatch(LoadInvoicesRequest()); store.dispatch(LoadInvoicesRequest());
repository repository

View File

@ -236,8 +236,7 @@ Middleware<AppState> _loadPayments(PaymentRepository repository) {
return; return;
} }
final int updatedAt = final int updatedAt = (state.paymentState.lastUpdated / 1000).round();
action.force ? 0 : (state.paymentState.lastUpdated / 1000).round();
store.dispatch(LoadPaymentsRequest()); store.dispatch(LoadPaymentsRequest());
repository repository

View File

@ -155,7 +155,7 @@ Middleware<AppState> _loadProducts(ProductRepository repository) {
return; return;
} }
final int updatedAt = action.force ? 0 : (state.productState.lastUpdated / 1000).round(); final int updatedAt = (state.clientState.lastUpdated / 1000).round();
store.dispatch(LoadProductsRequest()); store.dispatch(LoadProductsRequest());
repository.loadList(state.selectedCompany, state.authState, updatedAt).then((data) { repository.loadList(state.selectedCompany, state.authState, updatedAt).then((data) {

View File

@ -296,8 +296,7 @@ Middleware<AppState> _loadQuotes(QuoteRepository repository) {
return; return;
} }
final int updatedAt = final int updatedAt = (state.quoteState.lastUpdated / 1000).round();
action.force ? 0 : (state.quoteState.lastUpdated / 1000).round();
store.dispatch(LoadQuotesRequest()); store.dispatch(LoadQuotesRequest());
repository repository

View File

@ -27,7 +27,7 @@ class StubRepository {
Future<BuiltList<StubEntity>> loadList( Future<BuiltList<StubEntity>> loadList(
CompanyEntity company, AuthState auth, int updatedAt) async { CompanyEntity company, AuthState auth, int updatedAt) async {
String url = auth.url + '/stubs'; String url = auth.url + '/stubs?';
if (updatedAt > 0) { if (updatedAt > 0) {
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}'; url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';

View File

@ -204,8 +204,7 @@ Middleware<AppState> _loadStubs(StubRepository repository) {
return; return;
} }
final int updatedAt = final int updatedAt = (state.stubState.lastUpdated / 1000).round();
action.force ? 0 : (state.stubState.lastUpdated / 1000).round();
store.dispatch(LoadStubsRequest()); store.dispatch(LoadStubsRequest());
repository repository