feat(notification): 알림함 진입 및 딥링크 라우팅을 추가한다
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import Foundation
|
||||
|
||||
struct GetPushNotificationListResponse: Decodable {
|
||||
let totalCount: Int
|
||||
let items: [PushNotificationListItem]
|
||||
}
|
||||
|
||||
struct PushNotificationListItem: Decodable {
|
||||
let id: Int
|
||||
let senderNickname: String
|
||||
let senderProfileImage: String?
|
||||
let message: String
|
||||
let category: String
|
||||
let deepLink: String?
|
||||
let sentAt: String
|
||||
}
|
||||
|
||||
extension PushNotificationListItem {
|
||||
func relativeSentAtText(now: Date = Date()) -> String {
|
||||
guard let sentDate = DateParser.parse(sentAt) else {
|
||||
return sentAt
|
||||
}
|
||||
|
||||
let interval = max(0, now.timeIntervalSince(sentDate))
|
||||
if interval < 60 {
|
||||
return I18n.Time.justNow
|
||||
}
|
||||
|
||||
if interval < 3600 {
|
||||
let minutes = max(1, Int(interval / 60))
|
||||
return I18n.Time.minutesAgo(minutes)
|
||||
}
|
||||
|
||||
if interval < 86_400 {
|
||||
let hours = max(1, Int(interval / 3600))
|
||||
return I18n.Time.hoursAgo(hours)
|
||||
}
|
||||
|
||||
let days = max(1, Int(interval / 86_400))
|
||||
return I18n.Time.daysAgo(days)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user