Skip to content

Commit

Permalink
fix: Display correct plural form for NoValidMailboxes strings
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Nov 22, 2024
1 parent 976e3ed commit c0b55ca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class NoValidMailboxesFragment : Fragment(), MailboxListFragment {
setupAdapters()
setupListeners()

observeMailboxesCount()
observeMailboxesLive()
}

Expand Down Expand Up @@ -97,23 +96,13 @@ class NoValidMailboxesFragment : Fragment(), MailboxListFragment {
noValidMailboxesViewModel.invalidPasswordMailboxesLive.observe(viewLifecycleOwner) { invalidPasswordMailboxes ->
invalidPasswordMailboxesAdapter.setMailboxes(invalidPasswordMailboxes)
invalidPasswordMailboxesGroup.isVisible = invalidPasswordMailboxes.isNotEmpty()
invalidPasswordTitle.text = resources.getQuantityString(R.plurals.blockedPasswordTitle, invalidPasswordMailboxes.count())
}

noValidMailboxesViewModel.lockedMailboxesLive.observe(viewLifecycleOwner) { lockedMailboxes ->
mailboxesAdapter.setMailboxes(lockedMailboxes)
lockedMailboxesGroup.isVisible = lockedMailboxes.isNotEmpty()
lockedMailboxTitle.text = resources.getQuantityString(R.plurals.lockedMailboxTitle, lockedMailboxes.count())
}
}

private fun observeMailboxesCount() {
noValidMailboxesViewModel.mailboxesCountLive.observe(viewLifecycleOwner, ::setQuantityTextTitle)
}

private fun setQuantityTextTitle(mailboxCount: Long) = with(binding) {
val count = mailboxCount.toInt()
val lockedMailboxTitleString = resources.getQuantityString(R.plurals.lockedMailboxTitle, count)

invalidPasswordTitle.text = resources.getQuantityString(R.plurals.blockedPasswordTitle, count)
lockedMailboxTitle.text = lockedMailboxTitleString
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class NoValidMailboxesViewModel @Inject constructor(

private val ioCoroutineContext = viewModelScope.coroutineContext(ioDispatcher)

val mailboxesCountLive = mailboxController.getMailboxesCount(AccountUtils.currentUserId).asLiveData(ioCoroutineContext)

val lockedMailboxesLive = mailboxController.getLockedMailboxes(AccountUtils.currentUserId).asLiveData(ioCoroutineContext)

val invalidPasswordMailboxesLive = mailboxController.getInvalidPasswordMailboxes(AccountUtils.currentUserId)
Expand Down

0 comments on commit c0b55ca

Please sign in to comment.