-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPushNotificationQuery.swift
More file actions
46 lines (40 loc) · 974 Bytes
/
Copy pathPushNotificationQuery.swift
File metadata and controls
46 lines (40 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// PushNotificationQuery.swift
// DevLog
//
// Created by opfic on 2/18/26.
//
import Foundation
struct PushNotificationQuery: Equatable {
enum SortOrder: Equatable {
case latest
case oldest
}
enum TimeFilter: Equatable, Hashable {
case none
case hours(Int)
case days(Int)
}
var sortOrder: SortOrder
var timeFilter: TimeFilter
var unreadOnly: Bool
var pageSize: Int
static let `default` = PushNotificationQuery(
sortOrder: .latest,
timeFilter: .none,
unreadOnly: false,
pageSize: 20
)
}
extension PushNotificationQuery.TimeFilter {
var thresholdDate: Date? {
switch self {
case .none:
return nil
case .hours(let value):
return Date().addingTimeInterval(-Double(value) * 3600.0)
case .days(let value):
return Date().addingTimeInterval(-Double(value) * 86400.0)
}
}
}