Fix crash on TransactionFormViewModel creation
This commit is contained in:
parent
48d6eb6b00
commit
2bce5cf601
2 changed files with 4 additions and 1 deletions
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue