From f7ae87b158d133b01c89f903b9f82d4bebca967e Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 24 Dec 2019 23:17:43 +0200 Subject: [PATCH] Improve loading --- lib/data/repositories/auth_repository.dart | 8 ++++---- lib/redux/client/client_reducer.dart | 2 +- lib/redux/expense/expense_reducer.dart | 2 +- lib/redux/invoice/invoice_reducer.dart | 2 +- lib/redux/payment/payment_reducer.dart | 2 +- lib/redux/product/product_reducer.dart | 2 +- lib/redux/project/project_reducer.dart | 2 +- lib/redux/quote/quote_reducer.dart | 2 +- lib/redux/task/task_reducer.dart | 2 +- lib/redux/vendor/vendor_reducer.dart | 2 +- stubs/redux/stub/stub_reducer | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/data/repositories/auth_repository.dart b/lib/data/repositories/auth_repository.dart index cddfb08a0..32066f609 100644 --- a/lib/data/repositories/auth_repository.dart +++ b/lib/data/repositories/auth_repository.dart @@ -102,10 +102,10 @@ class AuthRepository { 'company.groups', 'company.company_gateways.gateway', 'company.clients', - 'company.products', - 'company.invoices', - 'company.payments', - 'company.quotes', + //'company.products', + //'company.invoices', + //'company.payments', + //'company.quotes', //'company.credits', //'company.tasks', //'company.projects', diff --git a/lib/redux/client/client_reducer.dart b/lib/redux/client/client_reducer.dart index 358838ebd..880bed887 100644 --- a/lib/redux/client/client_reducer.dart +++ b/lib/redux/client/client_reducer.dart @@ -350,7 +350,7 @@ ClientState _setLoadedClients( ClientState _companyLoaded( ClientState clientState, LoadCompanySuccess action) { final clients = action.userCompany.company.clients; - if (clients.isEmpty) { + if (clients == null || clients.isEmpty) { return clientState; } return clientState.loadClients(clients); diff --git a/lib/redux/expense/expense_reducer.dart b/lib/redux/expense/expense_reducer.dart index 18abea924..fe17eab58 100644 --- a/lib/redux/expense/expense_reducer.dart +++ b/lib/redux/expense/expense_reducer.dart @@ -306,7 +306,7 @@ ExpenseState _setLoadedExpenses( ExpenseState _companyLoaded( ExpenseState expenseState, LoadCompanySuccess action) { final expenses = action.userCompany.company.expenses; - if (expenses.isEmpty) { + if (expenses == null || expenses.isEmpty) { return expenseState; } return expenseState.loadExpenses(expenses); diff --git a/lib/redux/invoice/invoice_reducer.dart b/lib/redux/invoice/invoice_reducer.dart index eaee63bde..a1c05a536 100644 --- a/lib/redux/invoice/invoice_reducer.dart +++ b/lib/redux/invoice/invoice_reducer.dart @@ -409,7 +409,7 @@ InvoiceState _setLoadedInvoices( InvoiceState _companyLoaded( InvoiceState invoiceState, LoadCompanySuccess action) { final invoices = action.userCompany.company.invoices; - if (invoices.isEmpty) { + if (invoices == null || invoices.isEmpty) { return invoiceState; } return invoiceState.loadInvoices(invoices); diff --git a/lib/redux/payment/payment_reducer.dart b/lib/redux/payment/payment_reducer.dart index 475efaa0c..31afb413f 100644 --- a/lib/redux/payment/payment_reducer.dart +++ b/lib/redux/payment/payment_reducer.dart @@ -295,7 +295,7 @@ PaymentState _setLoadedPayments( PaymentState _companyLoaded( PaymentState paymentState, LoadCompanySuccess action) { final payments = action.userCompany.company.payments; - if (payments.isEmpty) { + if (payments == null || payments.isEmpty) { return paymentState; } return paymentState.loadPayments(payments); diff --git a/lib/redux/product/product_reducer.dart b/lib/redux/product/product_reducer.dart index cd0b26935..bc78494cc 100644 --- a/lib/redux/product/product_reducer.dart +++ b/lib/redux/product/product_reducer.dart @@ -289,7 +289,7 @@ ProductState _setLoadedProducts( ProductState _companyLoaded( ProductState productState, LoadCompanySuccess action) { final products = action.userCompany.company.products; - if (products.isEmpty) { + if (products == null || products.isEmpty) { return productState; } return productState.loadProducts(products); diff --git a/lib/redux/project/project_reducer.dart b/lib/redux/project/project_reducer.dart index 82d64080f..e30bc11eb 100644 --- a/lib/redux/project/project_reducer.dart +++ b/lib/redux/project/project_reducer.dart @@ -312,7 +312,7 @@ ProjectState _setLoadedProjects( ProjectState _companyLoaded( ProjectState projectState, LoadCompanySuccess action) { final projects = action.userCompany.company.projects; - if (projects.isEmpty) { + if (projects == null || projects.isEmpty) { return projectState; } return projectState.loadProjects(projects); diff --git a/lib/redux/quote/quote_reducer.dart b/lib/redux/quote/quote_reducer.dart index ec1469415..f97d3cc2b 100644 --- a/lib/redux/quote/quote_reducer.dart +++ b/lib/redux/quote/quote_reducer.dart @@ -378,7 +378,7 @@ QuoteState _setLoadedQuotes(QuoteState quoteState, LoadQuotesSuccess action) => QuoteState _companyLoaded( QuoteState quoteState, LoadCompanySuccess action) { final quotes = action.userCompany.company.quotes; - if (quotes.isEmpty) { + if (quotes == null || quotes.isEmpty) { return quoteState; } return quoteState.loadQuotes(quotes); diff --git a/lib/redux/task/task_reducer.dart b/lib/redux/task/task_reducer.dart index a5039492a..9e8a0984b 100644 --- a/lib/redux/task/task_reducer.dart +++ b/lib/redux/task/task_reducer.dart @@ -288,7 +288,7 @@ TaskState _setLoadedTasks(TaskState taskState, LoadTasksSuccess action) => TaskState _companyLoaded( TaskState taskState, LoadCompanySuccess action) { final tasks = action.userCompany.company.tasks; - if (tasks.isEmpty) { + if (tasks == null || tasks.isEmpty) { return taskState; } return taskState.loadTasks(tasks); diff --git a/lib/redux/vendor/vendor_reducer.dart b/lib/redux/vendor/vendor_reducer.dart index 76f1b6ca9..44cc38d61 100644 --- a/lib/redux/vendor/vendor_reducer.dart +++ b/lib/redux/vendor/vendor_reducer.dart @@ -334,7 +334,7 @@ VendorState _setLoadedVendors( VendorState _companyLoaded( VendorState vendorState, LoadCompanySuccess action) { final vendors = action.userCompany.company.vendors; - if (vendors.isEmpty) { + if (vendors == null || vendors.isEmpty) { return vendorState; } return vendorState.loadVendors(vendors); diff --git a/stubs/redux/stub/stub_reducer b/stubs/redux/stub/stub_reducer index 38e648b47..f34ae823b 100644 --- a/stubs/redux/stub/stub_reducer +++ b/stubs/redux/stub/stub_reducer @@ -226,7 +226,7 @@ StubState _setLoadedStubs( StubState _companyLoaded( StubState stubState, LoadCompanySuccess action) { final stubs = action.userCompany.company.stubs; - if (stubs.isEmpty) { + if (stubs == null || stubs.isEmpty) { return stubState; } return stubState.loadStubs(stubs);