Skip to content

Instantly share code, notes, and snippets.

@lukaspili
Created May 18, 2017 16:31
Show Gist options
  • Select an option

  • Save lukaspili/d522ff211393a027d2177b95a782fdc2 to your computer and use it in GitHub Desktop.

Select an option

Save lukaspili/d522ff211393a027d2177b95a782fdc2 to your computer and use it in GitHub Desktop.
Boss
val postsQuery = ParseQuery.getQuery<ParseObject>("Post")
.whereExists("createdAt")
.whereExists("building")
.whereExists("author")
.include("building")
.include("photo")
.include("author")
.include("author.Picture")
.whereEqualTo("building", ParseObject.createWithoutData("Building", sessionManager.buildingId))
.setLimit(QUERY_LIMIT)
.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE)
when (tab) {
FeedTabController.Tab.AllPosts -> {
postsQuery.whereEqualTo("category", "community")
}
FeedTabController.Tab.TenantPosts -> {
postsQuery
.whereDoesNotExist("stickyUntil")
.whereEqualTo("category", "community")
.whereMatchesQuery("author", ParseUser.getQuery().whereNotEqualTo("AccessLevel", "Manager"))
}
FeedTabController.Tab.ManagerPosts -> {
postsQuery
.whereEqualTo("category", "community")
.whereMatchesQuery("author", ParseUser.getQuery().whereEqualTo("AccessLevel", "Manager"))
}
FeedTabController.Tab.FeedbackPosts -> {
postsQuery.whereContainedIn("category", listOf("issue", "compliment"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment