Skip to content

Commit

Permalink
Remove !! from loadCategories() function
Browse files Browse the repository at this point in the history
Co-Authored-By: Irfan Ömür <[email protected]>
  • Loading branch information
neeldoshii and irfano committed Jun 19, 2024
1 parent 2ac2694 commit 4cf519e
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class AddCategoryFragment : AppCompatDialogFragment() {
private var site: SiteModel? = null
private var binding: AddCategoryBinding? = null

@set:Inject
var taxonomyStore: TaxonomyStore? = null
@Inject
lateinit var taxonomyStore: TaxonomyStore

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
(requireActivity().application as WordPress).component().inject(this)
Expand Down Expand Up @@ -93,11 +93,7 @@ class AddCategoryFragment : AppCompatDialogFragment() {
}

private fun loadCategories() {
val rootCategory = CategoryNode.createCategoryTreeFromList(
taxonomyStore!!.getCategoriesForSite(
site!!
)
)
val rootCategory = site?.let { CategoryNode.createCategoryTreeFromList(taxonomyStore.getCategoriesForSite(it)) }
val categoryLevels = CategoryNode.getSortedListOfCategoriesFromRoot(rootCategory)
categoryLevels.add(0, CategoryNode(0, 0, getString(R.string.top_level_category_name)))
if (categoryLevels.size > 0) {
Expand Down

0 comments on commit 4cf519e

Please sign in to comment.