Línea 6... |
Línea 6... |
6 |
//
|
6 |
//
|
Línea 7... |
Línea 7... |
7 |
|
7 |
|
Línea 8... |
Línea 8... |
8 |
import Foundation
|
8 |
import Foundation
|
- |
|
9 |
|
Línea -... |
Línea 10... |
- |
|
10 |
class AppData {
|
- |
|
11 |
private let standardPreference = UserDefaults.standard
|
9 |
|
12 |
|
10 |
class AppData {
|
13 |
|
11 |
|
14 |
|
Línea 12... |
Línea 15... |
12 |
var deviceUuid : String = ""
|
15 |
var deviceUuid : String = ""
|
Línea 34... |
Línea 37... |
34 |
var refreshContentMessageShowPending : Bool = false
|
37 |
var refreshContentMessageShowPending : Bool = false
|
35 |
var refreshContentActionRequired : Bool = false
|
38 |
var refreshContentActionRequired : Bool = false
|
36 |
var signoutActionRequired : Bool = false
|
39 |
var signoutActionRequired : Bool = false
|
Línea -... |
Línea 40... |
- |
|
40 |
|
37 |
|
41 |
|
Línea 38... |
Línea 42... |
38 |
|
42 |
/*
|
39 |
private let appDao = AppDao.sharedInstance
|
43 |
private let appDao = AppDao.sharedInstance
|
Línea 40... |
Línea 44... |
40 |
|
44 |
|
41 |
|
45 |
|
Línea 42... |
Línea 46... |
42 |
static let sharedInstance: AppData = {
|
46 |
static let sharedInstance: AppData = {
|
43 |
let instance = AppData()
|
47 |
let instance = AppData()
|
44 |
|
48 |
|
Línea 45... |
Línea 49... |
45 |
return instance
|
49 |
return instance
|
46 |
}()
|
50 |
}()*/
|
Línea 47... |
Línea -... |
47 |
|
- |
|
Línea -... |
Línea 51... |
- |
|
51 |
|
- |
|
52 |
init() {
|
48 |
init() {
|
53 |
load()
|
- |
|
54 |
}
|
- |
|
55 |
|
49 |
load()
|
56 |
func load() -> Void
|
50 |
}
|
57 |
{
|
51 |
|
58 |
|
52 |
func load() -> Void
|
59 |
|
53 |
{
|
60 |
|
54 |
|
61 |
|
55 |
let appModel = appDao.selectOne()
|
62 |
// let appModel = appDao.selectOne()
|
56 |
|
63 |
|
Línea 57... |
Línea 64... |
57 |
self.deviceUuid = appModel.deviceUuid
|
64 |
self.deviceUuid = standardPreference.string(forKey: Constants.PREFERENCE_DEVICE_UUID) ?? ""
|
58 |
self.devicePassword = appModel.devicePassword
|
65 |
self.devicePassword = standardPreference.string(forKey: Constants.PREFERENCE_DEVICE_PASSWORD) ?? ""
|
59 |
self.deviceAes = appModel.deviceAes
|
66 |
self.deviceAes = standardPreference.string(forKey: Constants.PREFERENCE_DEVICE_AES) ?? ""
|
60 |
|
67 |
|
61 |
self.userUuid = appModel.userUuid
|
68 |
self.userUuid = standardPreference.string(forKey: Constants.PREFERENCE_USER_UUID) ?? ""
|
62 |
self.userEmail = appModel.userEmail
|
69 |
self.userEmail = standardPreference.string(forKey: Constants.PREFERENCE_USER_EMAIL) ?? ""
|
63 |
self.userFirstname = appModel.userFirstname
|
70 |
self.userFirstname = standardPreference.string(forKey: Constants.PREFERENCE_USER_FIRSTNAME) ?? ""
|
64 |
self.userLastname = appModel.userLastname
|
71 |
self.userLastname = standardPreference.string(forKey: Constants.PREFERENCE_USER_LASTNAME) ?? ""
|
65 |
self.userImage = appModel.userImage
|
72 |
self.userImage = standardPreference.string(forKey: Constants.PREFERENCE_USER_IMAGE) ?? ""
|
66 |
|
73 |
|
67 |
self.topicUuidActive = appModel.topicUuidActive
|
74 |
self.topicUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_TOPIC_UUID_ACTIVE) ?? ""
|
68 |
self.capsuleUuidActive = appModel.capsuleUuidActive
|
75 |
self.capsuleUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_CAPSULE_UUID_ACTIVE) ?? ""
|
69 |
self.capsuleUuidOld = appModel.capsuleUuidOld
|
76 |
self.capsuleUuidOld = standardPreference.string(forKey: Constants.PREFERENCE_CAPSULE_UUID_OLD) ?? ""
|
70 |
self.slideUuidActive = appModel.slideUuidActive
|
77 |
self.slideUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_SLIDE_UUID_ACTIVE) ?? ""
|
Línea 71... |
Línea 78... |
71 |
self.companyUuidActive = appModel.companyUuidActive
|
78 |
self.companyUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_COMPANY_UUID_ACTIVE) ?? ""
|
Línea 72... |
Línea 79... |
72 |
|
79 |
|
73 |
self.fcmToken = appModel.fcmToken
|
80 |
self.fcmToken = standardPreference.string(forKey: Constants.PREFERENCE_FCM_TOKEN) ?? ""
|
74 |
self.lastCheckChanges = appModel.lastCheckChanges
|
81 |
self.lastCheckChanges = standardPreference.string(forKey: Constants.PREFERENCE_LAST_CHECK_CHANGES) ?? ""
|
75 |
self.maxDateChanges = appModel.maxDateChanges
|
82 |
self.maxDateChanges = standardPreference.string(forKey: Constants.PREFERENCE_MAX_DATE_CHANGES) ?? ""
|
Línea 141... |
Línea 148... |
141 |
print("AppData Save RefreshContentActionRequired : \(self.refreshContentActionRequired)")
|
148 |
print("AppData Save RefreshContentActionRequired : \(self.refreshContentActionRequired)")
|
Línea 142... |
Línea 149... |
142 |
|
149 |
|
143 |
print("AppData Save SignoutActionRequired : \(self.signoutActionRequired)")
|
150 |
print("AppData Save SignoutActionRequired : \(self.signoutActionRequired)")
|
Línea 144... |
Línea -... |
144 |
*/
|
- |
|
- |
|
151 |
*/
|
145 |
|
152 |
|
146 |
var appModel = appDao.selectOne()
|
- |
|
147 |
appModel.deviceUuid = self.deviceUuid
|
- |
|
148 |
appModel.deviceAes = self.deviceAes
|
153 |
|
- |
|
154 |
standardPreference.set(self.deviceUuid, forKey: Constants.PREFERENCE_DEVICE_UUID)
|
- |
|
155 |
|
149 |
appModel.devicePassword = self.devicePassword
|
156 |
standardPreference.set(self.devicePassword, forKey: Constants.PREFERENCE_DEVICE_PASSWORD)
|
150 |
|
157 |
standardPreference.set(self.deviceAes, forKey: Constants.PREFERENCE_DEVICE_AES)
|
151 |
appModel.userUuid = self.userUuid
|
158 |
standardPreference.set(self.userUuid, forKey: Constants.PREFERENCE_USER_UUID)
|
152 |
appModel.userFirstname = self.userFirstname
|
159 |
standardPreference.set(self.userEmail, forKey: Constants.PREFERENCE_USER_EMAIL)
|
153 |
appModel.userLastname = self.userLastname
|
160 |
standardPreference.set(self.userFirstname, forKey: Constants.PREFERENCE_USER_FIRSTNAME)
|
154 |
appModel.userEmail = self.userEmail
|
161 |
standardPreference.set(self.userLastname, forKey: Constants.PREFERENCE_USER_LASTNAME)
|
155 |
appModel.userImage = self.userImage
|
162 |
standardPreference.set(self.userImage, forKey: Constants.PREFERENCE_USER_IMAGE)
|
156 |
|
163 |
|
157 |
appModel.topicUuidActive = self.topicUuidActive
|
164 |
standardPreference.set(self.topicUuidActive, forKey: Constants.PREFERENCE_TOPIC_UUID_ACTIVE)
|
158 |
appModel.capsuleUuidActive = self.capsuleUuidActive
|
165 |
standardPreference.set(self.capsuleUuidActive, forKey: Constants.PREFERENCE_CAPSULE_UUID_ACTIVE)
|
159 |
appModel.capsuleUuidOld = self.capsuleUuidOld
|
166 |
standardPreference.set(self.capsuleUuidOld, forKey: Constants.PREFERENCE_CAPSULE_UUID_OLD)
|
160 |
appModel.slideUuidActive = self.slideUuidActive
|
- |
|
161 |
appModel.companyUuidActive = self.companyUuidActive
|
167 |
standardPreference.set(self.slideUuidActive, forKey: Constants.PREFERENCE_SLIDE_UUID_ACTIVE)
|
162 |
|
168 |
standardPreference.set(self.companyUuidActive, forKey: Constants.PREFERENCE_COMPANY_UUID_ACTIVE)
|
163 |
appModel.fcmToken = self.fcmToken
|
169 |
standardPreference.set(self.fcmToken, forKey: Constants.PREFERENCE_FCM_TOKEN)
|
164 |
appModel.lastCheckChanges = self.lastCheckChanges
|
170 |
standardPreference.set(self.lastCheckChanges, forKey: Constants.PREFERENCE_LAST_CHECK_CHANGES)
|
165 |
appModel.maxDateChanges = self.maxDateChanges
|
171 |
standardPreference.set(self.maxDateChanges, forKey: Constants.PREFERENCE_MAX_DATE_CHANGES)
|
166 |
appModel.urlExternalDownloaded = self.urlExternalDownloaded
|
172 |
standardPreference.set(self.urlExternalDownloaded, forKey: Constants.PREFERENCE_URL_EXTERNAL_DOWNLOADED)
|
167 |
|
173 |
|
168 |
appModel.refreshContentMessage = self.refreshContentMessage
|
174 |
standardPreference.set(self.refreshContentMessage, forKey: Constants.PREFERENCE_REFRESH_CONTENT_MESSAGE)
|
169 |
appModel.refreshContentMessageShowPending = self.refreshContentMessageShowPending
|
175 |
standardPreference.set(self.refreshContentMessageShowPending, forKey: Constants.PREFERENCE_REFRESH_CONTENT_MESSAGE_SHOW_PENDING)
|
170 |
appModel.refreshContentActionRequired = self.refreshContentActionRequired
|
176 |
standardPreference.set(self.refreshContentActionRequired, forKey: Constants.PREFERENCE_REFRESH_CONTENT_ACTION_REQUIRED)
|
171 |
|
- |
|
172 |
appModel.signoutActionRequired = self.signoutActionRequired
|
- |
|
173 |
|
- |
|
174 |
if appModel.id == 0 {
|
- |
|
175 |
appModel.id = appDao.insert(model: appModel)
|
- |
|
176 |
} else {
|
- |
|
177 |
appDao.update(model: appModel)
|
177 |
|
178 |
}
|
178 |
standardPreference.set(self.signoutActionRequired, forKey: Constants.PREFERENCE_SIGNOUT_ACTION_REQUIRED)
|