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

main.com.sceyt.chatuikit.persistence.mappers.MessageMarkerMapper.kt Maven / Gradle / Ivy

package com.sceyt.chatuikit.persistence.mappers

import com.sceyt.chat.models.message.Marker
import com.sceyt.chat.models.user.User
import com.sceyt.chatuikit.data.models.messages.SceytMarker
import com.sceyt.chatuikit.data.models.messages.SceytUser
import com.sceyt.chatuikit.persistence.entity.messages.MarkerEntity
import com.sceyt.chatuikit.persistence.entity.messages.MarkerWithUserDb

fun MarkerEntity.toSceytMarker(user: SceytUser) = SceytMarker(messageId, user, name, createdAt)

fun MarkerWithUserDb.toMarker(): SceytMarker {
    return with(entity) {
        val user = user?.toSceytUser() ?: SceytUser(userId)
        SceytMarker(messageId, user, name, createdAt)
    }
}

fun SceytMarker.toMarkerEntity() = MarkerEntity(messageId, userId, name, createdAt)

fun Marker.toSceytMarker() = SceytMarker(messageId, user.toSceytUser(), name, createdAt)

fun SceytMarker.toMarker() = Marker(messageId, user?.toUser() ?: User(userId), name, createdAt)





© 2015 - 2024 Weber Informatics LLC | Privacy Policy