diff --git a/android/src/main/java/com/wbrawner/budget/ui/transactions/TransactionFormActivity.kt b/android/src/main/java/com/wbrawner/budget/ui/transactions/TransactionFormActivity.kt index 6cc875c..48abe77 100644 --- a/android/src/main/java/com/wbrawner/budget/ui/transactions/TransactionFormActivity.kt +++ b/android/src/main/java/com/wbrawner/budget/ui/transactions/TransactionFormActivity.kt @@ -47,6 +47,7 @@ class TransactionFormActivity : AppCompatActivity(), CoroutineScope { setTitle(R.string.title_add_transaction) edit_transaction_type_expense.isChecked = true (application as AllowanceApplication).appComponent.inject(viewModel) + viewModel.init() launch { val accounts = viewModel.getAccounts().toTypedArray() setCategories() diff --git a/android/src/main/java/com/wbrawner/budget/ui/transactions/TransactionFormViewModel.kt b/android/src/main/java/com/wbrawner/budget/ui/transactions/TransactionFormViewModel.kt index 808a6ab..4bafb3d 100644 --- a/android/src/main/java/com/wbrawner/budget/ui/transactions/TransactionFormViewModel.kt +++ b/android/src/main/java/com/wbrawner/budget/ui/transactions/TransactionFormViewModel.kt @@ -20,10 +20,12 @@ class TransactionFormViewModel : ViewModel() { @Inject lateinit var userRepository: UserRepository + var currentUserId: Long? = null private set - init { + //TODO: Find a better way to handle this + fun init() { userRepository.currentUser.observeForever { currentUserId = it?.id }