Do not re-save profiles on (de)activate
Only service JSON is affected.
This commit is contained in:
parent
f120c51efe
commit
bc0568cc38
|
@ -57,7 +57,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
|
|||
func applicationWillResignActive(_ application: UIApplication) {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
|
||||
TransientStore.shared.serialize() // synchronize
|
||||
TransientStore.shared.serialize(withProfiles: true) // synchronize
|
||||
}
|
||||
|
||||
func applicationDidEnterBackground(_ application: UIApplication) {
|
||||
|
|
|
@ -421,7 +421,7 @@ extension OrganizerViewController {
|
|||
|
||||
extension OrganizerViewController: ConnectionServiceDelegate {
|
||||
func connectionService(didAdd profile: ConnectionProfile) {
|
||||
TransientStore.shared.serialize() // add
|
||||
TransientStore.shared.serialize(withProfiles: true) // add
|
||||
|
||||
reloadModel()
|
||||
tableView.reloadData()
|
||||
|
@ -444,14 +444,14 @@ extension OrganizerViewController: ConnectionServiceDelegate {
|
|||
}
|
||||
|
||||
func connectionService(didRename oldProfile: ConnectionProfile, to newProfile: ConnectionProfile) {
|
||||
TransientStore.shared.serialize() // rename
|
||||
TransientStore.shared.serialize(withProfiles: true) // rename
|
||||
|
||||
reloadModel()
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
func connectionService(didRemoveProfileWithKey key: ConnectionService.ProfileKey) {
|
||||
TransientStore.shared.serialize() // delete
|
||||
TransientStore.shared.serialize(withProfiles: true) // delete
|
||||
|
||||
splitViewController?.serviceViewController?.hideProfileIfDeleted()
|
||||
}
|
||||
|
@ -459,13 +459,13 @@ extension OrganizerViewController: ConnectionServiceDelegate {
|
|||
// XXX: deactivate + activate leads to a redundant serialization
|
||||
|
||||
func connectionService(willDeactivate profile: ConnectionProfile) {
|
||||
TransientStore.shared.serialize() // deactivate
|
||||
TransientStore.shared.serialize(withProfiles: false) // deactivate
|
||||
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
func connectionService(didActivate profile: ConnectionProfile) {
|
||||
TransientStore.shared.serialize() // activate
|
||||
TransientStore.shared.serialize(withProfiles: false) // activate
|
||||
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
|
|
@ -77,8 +77,10 @@ class TransientStore {
|
|||
}
|
||||
}
|
||||
|
||||
func serialize() {
|
||||
func serialize(withProfiles: Bool) {
|
||||
try? JSONEncoder().encode(service).write(to: TransientStore.serviceURL)
|
||||
service.saveProfiles()
|
||||
if withProfiles {
|
||||
service.saveProfiles()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue