Divide MessageRepository into itself and Conversation Repository

This commit is contained in:
Moez Bhatti
2018-06-15 22:08:05 -04:00
parent 6e14b1ab11
commit 1b022e46e3
28 changed files with 418 additions and 351 deletions
@@ -0,0 +1,46 @@
package repository
import io.realm.RealmResults
import model.Conversation
import model.SearchResult
interface ConversationRepository {
fun getConversations(archived: Boolean = false): RealmResults<Conversation>
fun getConversationsSnapshot(): List<Conversation>
fun setConversationName(id: Long, name: String)
fun searchConversations(query: String): List<SearchResult>
fun getBlockedConversations(): RealmResults<Conversation>
fun getConversationAsync(threadId: Long): Conversation
fun getConversation(threadId: Long): Conversation?
fun getOrCreateConversation(threadId: Long): Conversation?
fun getOrCreateConversation(address: String): Conversation?
fun getOrCreateConversation(addresses: List<String>): Conversation?
fun saveDraft(threadId: Long, draft: String)
/**
* Updates message-related fields in the conversation, like the date and snippet
*/
fun updateConversations(vararg threadIds: Long)
fun markArchived(vararg threadIds: Long)
fun markUnarchived(vararg threadIds: Long)
fun markBlocked(vararg threadIds: Long)
fun markUnblocked(vararg threadIds: Long)
fun deleteConversations(vararg threadIds: Long)
}
@@ -20,35 +20,11 @@ package repository
import io.realm.RealmResults
import model.Attachment
import model.Conversation
import model.Message
import model.MmsPart
import model.SearchResult
interface MessageRepository {
fun getConversations(archived: Boolean = false): RealmResults<Conversation>
fun getConversationsSnapshot(): List<Conversation>
fun setConversationName(id: Long, name: String)
fun searchConversations(query: String): List<SearchResult>
fun getBlockedConversations(): RealmResults<Conversation>
fun getConversationAsync(threadId: Long): Conversation
fun getConversation(threadId: Long): Conversation?
fun getOrCreateConversation(threadId: Long): Conversation?
fun getOrCreateConversation(address: String): Conversation?
fun getOrCreateConversation(addresses: List<String>): Conversation?
fun saveDraft(threadId: Long, draft: String)
fun getMessages(threadId: Long, query: String = ""): RealmResults<Message>
fun getMessage(id: Long): Message?
@@ -73,19 +49,6 @@ interface MessageRepository {
*/
fun getUnreadMessages(threadId: Long): RealmResults<Message>
/**
* Updates message-related fields in the conversation, like the date and snippet
*/
fun updateConversations(vararg threadIds: Long)
fun markArchived(vararg threadIds: Long)
fun markUnarchived(vararg threadIds: Long)
fun markBlocked(vararg threadIds: Long)
fun markUnblocked(vararg threadIds: Long)
fun markAllSeen()
fun markSeen(threadId: Long)
@@ -130,6 +93,4 @@ interface MessageRepository {
fun deleteMessages(vararg messageIds: Long)
fun deleteConversations(vararg threadIds: Long)
}