Skip to content

Instantly share code, notes, and snippets.

@RobertApikyan
Created February 8, 2019 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertApikyan/65f0a2b9bbee82cc1e415e9bdf3dabb0 to your computer and use it in GitHub Desktop.
Save RobertApikyan/65f0a2b9bbee82cc1e415e9bdf3dabb0 to your computer and use it in GitHub Desktop.
{ companies ->
val ac = mutableListOf<Company.UserAccessViewModel>()
for (company in companies) {
val status = UserManegmentCompanyStatus.firstOrUndefined(company.approvalStatus)
val hasAccess = userCompanyList.indexOfFirst { it.id == company.id }.isNotUndefined
if (status == UserManegmentCompanyStatus.APPROVED || (status == UserManegmentCompanyStatus.WAITING && hasAccess)) {
ac.add(Company.UserAccessViewModel(company, hasAccess))
}
}
ac.sortBy { !it.hasAccess }
return@mutateAsync ac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment