#965 - Add ability to pin conversations

This commit is contained in:
Moez Bhatti
2018-07-23 14:37:42 -04:00
parent fbd7c7b3a1
commit cb62bcee1d
15 changed files with 215 additions and 31 deletions
@@ -36,7 +36,7 @@ class ConversationRepositoryImpl @Inject constructor(
.equalTo("archived", archived)
.equalTo("blocked", false)
.isNotEmpty("recipients")
.sort("date", Sort.DESCENDING)
.sort("pinned", Sort.DESCENDING, "date", Sort.DESCENDING)
.findAllAsync()
}
@@ -48,7 +48,7 @@ class ConversationRepositoryImpl @Inject constructor(
.equalTo("archived", false)
.equalTo("blocked", false)
.isNotEmpty("recipients")
.sort("date", Sort.DESCENDING)
.sort("pinned", Sort.DESCENDING, "date", Sort.DESCENDING)
.findAll())
}
@@ -206,6 +206,30 @@ class ConversationRepositoryImpl @Inject constructor(
}
}
override fun markPinned(vararg threadIds: Long) {
Realm.getDefaultInstance().use { realm ->
val conversations = realm.where(Conversation::class.java)
.anyOf("id", threadIds)
.findAll()
realm.executeTransaction {
conversations.forEach { it.pinned = true }
}
}
}
override fun markUnpinned(vararg threadIds: Long) {
Realm.getDefaultInstance().use { realm ->
val conversations = realm.where(Conversation::class.java)
.anyOf("id", threadIds)
.findAll()
realm.executeTransaction {
conversations.forEach { it.pinned = false }
}
}
}
override fun markBlocked(vararg threadIds: Long) {
Realm.getDefaultInstance().use { realm ->
val conversations = realm.where(Conversation::class.java)