mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Refactor ConversationMessagePair to InboxItem
This commit is contained in:
+1
-1
@@ -3,4 +3,4 @@ package com.moez.QKSMS.data.model
|
||||
/**
|
||||
* Groups a conversation with its latest message into a single model
|
||||
*/
|
||||
data class ConversationMessagePair(val conversation: Conversation, val message: Message)
|
||||
data class InboxItem(val conversation: Conversation, val message: Message)
|
||||
@@ -14,7 +14,7 @@ import com.moez.QKSMS.common.util.extensions.insertOrUpdate
|
||||
import com.moez.QKSMS.data.mapper.CursorToConversation
|
||||
import com.moez.QKSMS.data.mapper.CursorToMessage
|
||||
import com.moez.QKSMS.data.model.Conversation
|
||||
import com.moez.QKSMS.data.model.ConversationMessagePair
|
||||
import com.moez.QKSMS.data.model.InboxItem
|
||||
import com.moez.QKSMS.data.model.Message
|
||||
import io.reactivex.Flowable
|
||||
import io.reactivex.Maybe
|
||||
@@ -33,7 +33,7 @@ class MessageRepository @Inject constructor(
|
||||
private val cursorToMessage: CursorToMessage,
|
||||
private val cursorToConversation: CursorToConversation) {
|
||||
|
||||
fun getConversations(archived: Boolean = false): Flowable<List<ConversationMessagePair>> {
|
||||
fun getConversations(archived: Boolean = false): Flowable<List<InboxItem>> {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
|
||||
val conversations = realm.where(Conversation::class.java)
|
||||
@@ -53,7 +53,7 @@ class MessageRepository @Inject constructor(
|
||||
return Flowable.combineLatest(conversations, messages, BiFunction { conversations, messages ->
|
||||
messages.mapNotNull { message ->
|
||||
val conversation = conversations[message.threadId]
|
||||
if (conversation == null) null else ConversationMessagePair(conversation, message)
|
||||
if (conversation == null) null else InboxItem(conversation, message)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.util.Colors
|
||||
import com.moez.QKSMS.common.util.DateFormatter
|
||||
import com.moez.QKSMS.data.model.Contact
|
||||
import com.moez.QKSMS.data.model.ConversationMessagePair
|
||||
import com.moez.QKSMS.data.model.InboxItem
|
||||
import com.moez.QKSMS.data.repository.MessageRepository
|
||||
import com.moez.QKSMS.presentation.Navigator
|
||||
import com.moez.QKSMS.presentation.common.base.FlowableAdapter
|
||||
@@ -27,7 +27,7 @@ class ConversationsAdapter @Inject constructor(
|
||||
val messageRepo: MessageRepository,
|
||||
val dateFormatter: DateFormatter,
|
||||
val colors: Colors
|
||||
) : FlowableAdapter<ConversationMessagePair>() {
|
||||
) : FlowableAdapter<InboxItem>() {
|
||||
|
||||
val longClicks: Subject<Long> = PublishSubject.create<Long>()
|
||||
|
||||
@@ -73,7 +73,7 @@ class ConversationsAdapter @Inject constructor(
|
||||
return if (getItem(position).message.read) 0 else 1
|
||||
}
|
||||
|
||||
override fun areItemsTheSame(old: ConversationMessagePair, new: ConversationMessagePair): Boolean {
|
||||
override fun areItemsTheSame(old: InboxItem, new: InboxItem): Boolean {
|
||||
return old.conversation.id == new.conversation.id
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.moez.QKSMS.presentation.main
|
||||
|
||||
import com.moez.QKSMS.data.model.ConversationMessagePair
|
||||
import com.moez.QKSMS.data.model.InboxItem
|
||||
import io.reactivex.Flowable
|
||||
|
||||
data class MainState(
|
||||
@@ -10,9 +10,9 @@ data class MainState(
|
||||
|
||||
sealed class MainPage
|
||||
|
||||
data class Inbox(val data: Flowable<List<ConversationMessagePair>>?) : MainPage()
|
||||
data class Inbox(val data: Flowable<List<InboxItem>>?) : MainPage()
|
||||
|
||||
data class Archived(val data: Flowable<List<ConversationMessagePair>>?) : MainPage()
|
||||
data class Archived(val data: Flowable<List<InboxItem>>?) : MainPage()
|
||||
|
||||
data class Scheduled(val data: Any? = null) : MainPage()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user