EmojiReactionsData.kt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package ch.threema.data.models
  2. import androidx.compose.runtime.Immutable
  3. import ch.threema.data.storage.DbEmojiReaction
  4. import ch.threema.domain.types.IdentityString
  5. import java.time.Instant
  6. @Immutable
  7. data class EmojiReactionData(
  8. /** The id of the message this reaction refers to - see [ch.threema.storage.models.AbstractMessageModel.COLUMN_ID] */
  9. @JvmField val messageId: Int,
  10. /** The identity of the person who reacted. This may differ from the sender of the message **/
  11. @JvmField val senderIdentity: IdentityString,
  12. /** The emoji codepoint sequence of the reaction. This can never be empty */
  13. @JvmField val emojiSequence: String,
  14. /** Timestamp when the reaction was locally created. */
  15. @JvmField val reactedAt: Instant,
  16. ) {
  17. override fun equals(other: Any?): Boolean {
  18. if (other !is EmojiReactionData) return false
  19. return this.messageId == other.messageId &&
  20. this.senderIdentity == other.senderIdentity &&
  21. this.emojiSequence == other.emojiSequence
  22. }
  23. override fun hashCode(): Int {
  24. var result = messageId
  25. result = 31 * result + senderIdentity.hashCode()
  26. result = 31 * result + emojiSequence.hashCode()
  27. return result
  28. }
  29. }
  30. fun DbEmojiReaction.toDataType() = EmojiReactionData(
  31. messageId = this.messageId,
  32. senderIdentity = this.senderIdentity,
  33. emojiSequence = this.emojiSequence,
  34. reactedAt = this.reactedAt.toInstant(),
  35. )