-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathOneTimeActions.swift
36 lines (30 loc) · 1.02 KB
/
OneTimeActions.swift
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
//
// OneTimeActions.swift
// LockdowniOS
//
// Created by Oleg Dreyman on 28.05.2020.
// Copyright © 2020 Confirmed Inc. All rights reserved.
//
import Foundation
enum OneTimeActions {
enum Flag: String {
case welcomeScreen = "LockdownHasSeenWelcomePopup"
case notificationAuthorizationRequestPopup = "LockdownHasSeenNotificationAuthorizationRequestPopup"
case oneHundredTrackingAttemptsBlockedNotification = "LockdownHasScheduledOneHundredTrackingAttemptsBlockedNotification"
case newEnableNotificationsController = "LockdownHasSeenNewEnableNotificationsController"
}
static func hasSeen(_ flag: Flag) -> Bool {
return defaults.bool(forKey: flag.rawValue)
}
static func markAsSeen(_ flag: Flag) {
defaults.set(true, forKey: flag.rawValue)
}
static func performOnce(ifHasNotSeen flag: Flag, action: () -> ()) {
if hasSeen(flag) {
return
} else {
markAsSeen(flag)
action()
}
}
}