package eu.gaudian.translator.model

import android.text.format.DateUtils
import kotlinx.serialization.Serializable

@Serializable
data class TranslationHistoryItem(
    val id: Long = System.currentTimeMillis(), // Unique ID for animations/deletion
    val text: String, // The result text
    val sourceText: String, // The original input
    val sourceLanguageCode: Int?, // nameResID
    val targetLanguageCode: Int?, // nameResID
    val playable: Boolean? = null,
    val timestamp: Long = System.currentTimeMillis(),
    val translationSource: String? = null,
    val translationModel: String? = null
) {
    fun getRelativeTimeSpan(): String {
        val now = System.currentTimeMillis()
        return DateUtils.getRelativeTimeSpanString(timestamp, now, DateUtils.MINUTE_IN_MILLIS).toString()
    }
}