Format
This commit is contained in:
@@ -23,6 +23,7 @@ abstract class CoreState with _$CoreState {
|
||||
@Default([]) List<BudgetItemDto> budgetItems,
|
||||
@Default(null) BudgetsDto? activeBudget,
|
||||
@Default([]) List<LoanDto> loans,
|
||||
@Default([]) List<LoanChange> loanChanges,
|
||||
@Default(null) LoanDto? activeLoan,
|
||||
@Default(false) bool isDeletingAccount,
|
||||
}) = _CoreState;
|
||||
@@ -40,6 +41,7 @@ class CoreCubit extends Cubit<CoreState> {
|
||||
StreamSubscription<void>? _budgetsStreamSubscription;
|
||||
StreamSubscription<void>? _budgetItemsStreamSubscription;
|
||||
StreamSubscription<void>? _loanStreamSubscription;
|
||||
StreamSubscription<void>? _loanChangesSubscription;
|
||||
|
||||
void setupAccountStream() {
|
||||
_accountsStreamSubscription?.cancel();
|
||||
@@ -95,7 +97,6 @@ class CoreCubit extends Cubit<CoreState> {
|
||||
_budgetsStreamSubscription = db.budgetsDao
|
||||
.budgetsStream(activeAccount!)
|
||||
.listen((budgets) async {
|
||||
print("BUDGETS: $budgets");
|
||||
emit(state.copyWith(budgets: budgets));
|
||||
});
|
||||
_loanStreamSubscription?.cancel();
|
||||
@@ -125,17 +126,6 @@ class CoreCubit extends Cubit<CoreState> {
|
||||
state.copyWith(
|
||||
accounts: accounts,
|
||||
activeAccountIndex: accounts.isEmpty ? null : 0,
|
||||
transactions: await db.transactionsDao.getTransactions(account),
|
||||
beneficiaries: await db.beneficiariesDao.getBeneficiaries(),
|
||||
transactionTemplates: await db.transactionTemplatesDao
|
||||
.getTransactionTemplates(account),
|
||||
recurringTransactions: await db.recurringTransactionsDao
|
||||
.getRecurringTransactions(account),
|
||||
expenseCategories: await db.expenseCategoriesDao.getExpenseCategories(
|
||||
account,
|
||||
),
|
||||
//budgets: await db.budgetsDao.getBudgets(account),
|
||||
loans: await db.loansDao.getLoans(account),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -211,8 +201,18 @@ class CoreCubit extends Cubit<CoreState> {
|
||||
await init();
|
||||
}
|
||||
|
||||
void setActiveLoan(LoanDto loan) {
|
||||
emit(state.copyWith(activeLoan: loan));
|
||||
void setActiveLoan(LoanDto? loan) {
|
||||
emit(state.copyWith(activeLoan: loan, loanChanges: []));
|
||||
_loanChangesSubscription?.cancel();
|
||||
if (loan != null) {
|
||||
_loanChangesSubscription = GetIt.I
|
||||
.get<OkaneDatabase>()
|
||||
.loansDao
|
||||
.watchLoanChanges(loan.loan)
|
||||
.listen((changes) {
|
||||
emit(state.copyWith(loanChanges: changes));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Account? get activeAccount =>
|
||||
|
||||
@@ -33,6 +33,7 @@ mixin _$CoreState {
|
||||
List<BudgetItemDto> get budgetItems => throw _privateConstructorUsedError;
|
||||
BudgetsDto? get activeBudget => throw _privateConstructorUsedError;
|
||||
List<LoanDto> get loans => throw _privateConstructorUsedError;
|
||||
List<LoanChange> get loanChanges => throw _privateConstructorUsedError;
|
||||
LoanDto? get activeLoan => throw _privateConstructorUsedError;
|
||||
bool get isDeletingAccount => throw _privateConstructorUsedError;
|
||||
|
||||
@@ -60,6 +61,7 @@ abstract class $CoreStateCopyWith<$Res> {
|
||||
List<BudgetItemDto> budgetItems,
|
||||
BudgetsDto? activeBudget,
|
||||
List<LoanDto> loans,
|
||||
List<LoanChange> loanChanges,
|
||||
LoanDto? activeLoan,
|
||||
bool isDeletingAccount,
|
||||
});
|
||||
@@ -91,6 +93,7 @@ class _$CoreStateCopyWithImpl<$Res, $Val extends CoreState>
|
||||
Object? budgetItems = null,
|
||||
Object? activeBudget = freezed,
|
||||
Object? loans = null,
|
||||
Object? loanChanges = null,
|
||||
Object? activeLoan = freezed,
|
||||
Object? isDeletingAccount = null,
|
||||
}) {
|
||||
@@ -161,6 +164,11 @@ class _$CoreStateCopyWithImpl<$Res, $Val extends CoreState>
|
||||
? _value.loans
|
||||
: loans // ignore: cast_nullable_to_non_nullable
|
||||
as List<LoanDto>,
|
||||
loanChanges:
|
||||
null == loanChanges
|
||||
? _value.loanChanges
|
||||
: loanChanges // ignore: cast_nullable_to_non_nullable
|
||||
as List<LoanChange>,
|
||||
activeLoan:
|
||||
freezed == activeLoan
|
||||
? _value.activeLoan
|
||||
@@ -200,6 +208,7 @@ abstract class _$$CoreStateImplCopyWith<$Res>
|
||||
List<BudgetItemDto> budgetItems,
|
||||
BudgetsDto? activeBudget,
|
||||
List<LoanDto> loans,
|
||||
List<LoanChange> loanChanges,
|
||||
LoanDto? activeLoan,
|
||||
bool isDeletingAccount,
|
||||
});
|
||||
@@ -230,6 +239,7 @@ class __$$CoreStateImplCopyWithImpl<$Res>
|
||||
Object? budgetItems = null,
|
||||
Object? activeBudget = freezed,
|
||||
Object? loans = null,
|
||||
Object? loanChanges = null,
|
||||
Object? activeLoan = freezed,
|
||||
Object? isDeletingAccount = null,
|
||||
}) {
|
||||
@@ -300,6 +310,11 @@ class __$$CoreStateImplCopyWithImpl<$Res>
|
||||
? _value._loans
|
||||
: loans // ignore: cast_nullable_to_non_nullable
|
||||
as List<LoanDto>,
|
||||
loanChanges:
|
||||
null == loanChanges
|
||||
? _value._loanChanges
|
||||
: loanChanges // ignore: cast_nullable_to_non_nullable
|
||||
as List<LoanChange>,
|
||||
activeLoan:
|
||||
freezed == activeLoan
|
||||
? _value.activeLoan
|
||||
@@ -332,6 +347,7 @@ class _$CoreStateImpl implements _CoreState {
|
||||
final List<BudgetItemDto> budgetItems = const [],
|
||||
this.activeBudget = null,
|
||||
final List<LoanDto> loans = const [],
|
||||
final List<LoanChange> loanChanges = const [],
|
||||
this.activeLoan = null,
|
||||
this.isDeletingAccount = false,
|
||||
}) : _accounts = accounts,
|
||||
@@ -342,7 +358,8 @@ class _$CoreStateImpl implements _CoreState {
|
||||
_expenseCategories = expenseCategories,
|
||||
_budgets = budgets,
|
||||
_budgetItems = budgetItems,
|
||||
_loans = loans;
|
||||
_loans = loans,
|
||||
_loanChanges = loanChanges;
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
@@ -439,6 +456,15 @@ class _$CoreStateImpl implements _CoreState {
|
||||
return EqualUnmodifiableListView(_loans);
|
||||
}
|
||||
|
||||
final List<LoanChange> _loanChanges;
|
||||
@override
|
||||
@JsonKey()
|
||||
List<LoanChange> get loanChanges {
|
||||
if (_loanChanges is EqualUnmodifiableListView) return _loanChanges;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_loanChanges);
|
||||
}
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final LoanDto? activeLoan;
|
||||
@@ -448,7 +474,7 @@ class _$CoreStateImpl implements _CoreState {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CoreState(activePage: $activePage, activeAccountIndex: $activeAccountIndex, activeTransaction: $activeTransaction, accounts: $accounts, recurringTransactions: $recurringTransactions, transactions: $transactions, transactionTemplates: $transactionTemplates, beneficiaries: $beneficiaries, expenseCategories: $expenseCategories, budgets: $budgets, budgetItems: $budgetItems, activeBudget: $activeBudget, loans: $loans, activeLoan: $activeLoan, isDeletingAccount: $isDeletingAccount)';
|
||||
return 'CoreState(activePage: $activePage, activeAccountIndex: $activeAccountIndex, activeTransaction: $activeTransaction, accounts: $accounts, recurringTransactions: $recurringTransactions, transactions: $transactions, transactionTemplates: $transactionTemplates, beneficiaries: $beneficiaries, expenseCategories: $expenseCategories, budgets: $budgets, budgetItems: $budgetItems, activeBudget: $activeBudget, loans: $loans, loanChanges: $loanChanges, activeLoan: $activeLoan, isDeletingAccount: $isDeletingAccount)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -491,6 +517,10 @@ class _$CoreStateImpl implements _CoreState {
|
||||
(identical(other.activeBudget, activeBudget) ||
|
||||
other.activeBudget == activeBudget) &&
|
||||
const DeepCollectionEquality().equals(other._loans, _loans) &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other._loanChanges,
|
||||
_loanChanges,
|
||||
) &&
|
||||
(identical(other.activeLoan, activeLoan) ||
|
||||
other.activeLoan == activeLoan) &&
|
||||
(identical(other.isDeletingAccount, isDeletingAccount) ||
|
||||
@@ -513,6 +543,7 @@ class _$CoreStateImpl implements _CoreState {
|
||||
const DeepCollectionEquality().hash(_budgetItems),
|
||||
activeBudget,
|
||||
const DeepCollectionEquality().hash(_loans),
|
||||
const DeepCollectionEquality().hash(_loanChanges),
|
||||
activeLoan,
|
||||
isDeletingAccount,
|
||||
);
|
||||
@@ -539,6 +570,7 @@ abstract class _CoreState implements CoreState {
|
||||
final List<BudgetItemDto> budgetItems,
|
||||
final BudgetsDto? activeBudget,
|
||||
final List<LoanDto> loans,
|
||||
final List<LoanChange> loanChanges,
|
||||
final LoanDto? activeLoan,
|
||||
final bool isDeletingAccount,
|
||||
}) = _$CoreStateImpl;
|
||||
@@ -570,6 +602,8 @@ abstract class _CoreState implements CoreState {
|
||||
@override
|
||||
List<LoanDto> get loans;
|
||||
@override
|
||||
List<LoanChange> get loanChanges;
|
||||
@override
|
||||
LoanDto? get activeLoan;
|
||||
@override
|
||||
bool get isDeletingAccount;
|
||||
|
||||
Reference in New Issue
Block a user