All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.com.sceyt.chatuikit.data.models.messages.SceytMessage.kt Maven / Gradle / Ivy

package com.sceyt.chatuikit.data.models.messages

import android.os.Parcelable
import com.sceyt.chat.models.message.BodyAttribute
import com.sceyt.chat.models.message.DeliveryStatus
import com.sceyt.chat.models.message.ForwardingDetails
import com.sceyt.chat.models.message.MarkerTotal
import com.sceyt.chat.models.message.MessageState
import com.sceyt.chat.models.message.ReactionTotal
import com.sceyt.chatuikit.presentation.components.channel.messages.adapters.files.FileListItem
import com.sceyt.chatuikit.presentation.components.channel.messages.adapters.reactions.ReactionItem
import kotlinx.parcelize.Parcelize

@Parcelize
data class SceytMessage(
        val id: Long,
        val tid: Long,
        val channelId: Long,
        val body: String,
        val type: String,
        val metadata: String?,
        val createdAt: Long,
        val updatedAt: Long,
        val incoming: Boolean,
        val isTransient: Boolean,
        val silent: Boolean,
        val deliveryStatus: DeliveryStatus,
        val state: MessageState,
        val user: SceytUser?,
        val attachments: List?,
        val userReactions: List?,
        val reactionTotals: List?,
        val markerTotals: List?,
        val userMarkers: List?,
        val mentionedUsers: List?,
        val parentMessage: SceytMessage?,
        val replyCount: Long,
        val displayCount: Short,
        val autoDeleteAt: Long?,
        val forwardingDetails: ForwardingDetails?,
        val pendingReactions: List?,
        val bodyAttributes: List?,
    // Local properties
        val shouldShowAvatarAndName: Boolean = false,
        val disabledShowAvatarAndName: Boolean = false,
        val isGroup: Boolean = false,
        val files: List? = null,
        val messageReactions: List? = null,
        val isSelected: Boolean = false
) : Parcelable, Cloneable {

    val isForwarded get() = (forwardingDetails?.messageId ?: 0L) > 0L

    // todo reply in thread
    val isReplied get() = parentMessage != null && parentMessage.id != 0L /*&& !replyInThread*/

    override fun equals(other: Any?): Boolean {
        if (other == null || other !is SceytMessage) return false

        return if (deliveryStatus == DeliveryStatus.Pending || other.deliveryStatus == DeliveryStatus.Pending)
            other.tid == tid
        else other.id == id
    }

    override fun hashCode(): Int {
        return javaClass.name.hashCode()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy