41 lines
1.2 KiB
Swift
41 lines
1.2 KiB
Swift
//
|
|
// EQNUserDefaultsCommand.swift
|
|
// Earthquake Network
|
|
//
|
|
// Created by Busi Andrea on 26/09/2020.
|
|
// Copyright © 2020 Earthquake Network. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
|
|
public class EQNUserDefaultsCommand: EQNCommandProtocol {
|
|
|
|
// MARK: - Public
|
|
|
|
func execute() {
|
|
print("EQNUserDefaultsCommand: start execute")
|
|
|
|
applyDefaultSettings()
|
|
saveMissingValues()
|
|
}
|
|
|
|
// MARK: - Private
|
|
|
|
private func applyDefaultSettings() {
|
|
|
|
// seismic card settings
|
|
if UserDefaults.standard.array(forKey: EQNUserDefaultKeySesmicInformations) == nil {
|
|
let informations: [SeismicNetworkTableViewCell.InformationType] = [.buttons, .distance, .coordinate, .population]
|
|
UserDefaults.standard.set(informations.map { $0.rawValue }, forKey: EQNUserDefaultKeySesmicInformations)
|
|
}
|
|
}
|
|
|
|
private func saveMissingValues() {
|
|
// `raggio sismi forti` was not saved before v2.3
|
|
if UserDefaults.standard.object(forKey: NOTIFICHE_ALLERA_SISMICA_RAGGIO_SISMI_FORTI) == nil {
|
|
UserDefaults.standard.set("600", forKey: NOTIFICHE_ALLERA_SISMICA_RAGGIO_SISMI_FORTI)
|
|
}
|
|
}
|
|
}
|