Skip to content

Commit

Permalink
Merge pull request #365 from apeun-gidaechi/feature/364-read-count-ti…
Browse files Browse the repository at this point in the history
…mestamp-in-img-file

Feature/Add read count and timestamp in Img, File Component
  • Loading branch information
8954sood authored Nov 14, 2024
2 parents a62cc5a + 67ba768 commit 472359a
Show file tree
Hide file tree
Showing 6 changed files with 421 additions and 101 deletions.
12 changes: 12 additions & 0 deletions common/src/main/java/com/seugi/common/utiles/Extension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,34 @@ import kotlinx.datetime.LocalDate

fun LocalDateTime.toDeviceLocalDateTime(): LocalDateTime = this.atZone(ZoneId.of("UTC")).withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime()

/**
* return to ex) 2024년 7월 14일 금요일
*/
fun LocalDateTime.toFullFormatString(): String {
val formatter = DateTimeFormatter.ofPattern("yyyy년 M월 d일 E요일", Locale.KOREAN)
return this.toDeviceLocalDateTime().format(formatter)
}

/**
* return to ex) 12:44
*/
fun LocalDateTime.toShortString(): String {
val formatter = DateTimeFormatter.ofPattern("HH:mm")
return this.toDeviceLocalDateTime().format(formatter)
}

/**
* return to ex) 오후 12:44
*/
fun LocalDateTime.toAmShortString(): String {
val time = this.toDeviceLocalDateTime()
val isAm = time.hour < 12
return (if (isAm) "오전" else "오후") + " " + time.minusHours(if (!isAm && time.hour != 12) 12 else 0).format(DateTimeFormatter.ofPattern("HH:mm"))
}

/**
* return to ex) 7월 11일
*/
fun LocalDateTime.toTimeString(): String {
val time = this.toDeviceLocalDateTime()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ internal fun MessageRoomEventResponse.MessageParent.Message.toModel(userId: Long
type = type.toMessageType(),
userId = this.userId,
uuid = uuid,
isFirst = false,
isLast = false,
)
}
"FILE" -> {
Expand All @@ -292,6 +294,8 @@ internal fun MessageRoomEventResponse.MessageParent.Message.toModel(userId: Long
type = type.toMessageType(),
userId = this.userId,
uuid = uuid,
isFirst = false,
isLast = false,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ sealed class MessageRoomEvent(
override val timestamp: LocalDateTime,
override val type: MessageType,
override val userId: Long,
val isFirst: Boolean,
val isLast: Boolean,
) : MessageParent(timestamp, type, userId)

data class Img(
Expand All @@ -208,6 +210,8 @@ sealed class MessageRoomEvent(
override val timestamp: LocalDateTime,
override val type: MessageType,
override val userId: Long,
val isFirst: Boolean,
val isLast: Boolean,
) : MessageParent(timestamp, type, userId)

data class Enter(
Expand Down
Loading

0 comments on commit 472359a

Please sign in to comment.