Export providers database in beta
This commit is contained in:
parent
abb23e8234
commit
cca2dca047
|
@ -33,8 +33,18 @@ import PassepartoutServices
|
|||
class AppContext {
|
||||
static let shared = AppContext()
|
||||
|
||||
private let persistenceManager: PersistenceManager
|
||||
private let profilesPersistence: Persistence
|
||||
|
||||
private let providersPersistence: Persistence
|
||||
|
||||
var urlsForProfiles: [URL]? {
|
||||
profilesPersistence.containerURLs
|
||||
}
|
||||
|
||||
var urlsForProviders: [URL]? {
|
||||
providersPersistence.containerURLs
|
||||
}
|
||||
|
||||
let appManager: AppManager
|
||||
|
||||
let providerManager: ProviderManager
|
||||
|
@ -63,7 +73,13 @@ class AppContext {
|
|||
appManager.configureLogging()
|
||||
pp_log.info("Logging to: \(appManager.logFile!)")
|
||||
|
||||
persistenceManager = PersistenceManager(author: appManager.persistenceAuthor)
|
||||
let persistenceManager = PersistenceManager(author: appManager.persistenceAuthor)
|
||||
profilesPersistence = persistenceManager.profilesPersistence(
|
||||
withName: Constants.Persistence.profilesContainerName
|
||||
)
|
||||
providersPersistence = persistenceManager.providersPersistence(
|
||||
withName: Constants.Persistence.providersContainerName
|
||||
)
|
||||
|
||||
providerManager = ProviderManager(
|
||||
appBuild: Constants.Global.appBuildNumber,
|
||||
|
@ -75,9 +91,7 @@ class AppContext {
|
|||
Constants.Repos.api,
|
||||
timeout: Constants.Services.connectivityTimeout
|
||||
),
|
||||
persistence: persistenceManager.providersPersistence(
|
||||
withName: Constants.Persistence.providersContainerName
|
||||
)
|
||||
persistence: providersPersistence
|
||||
)
|
||||
|
||||
profileManager = ProfileManager(
|
||||
|
@ -85,9 +99,7 @@ class AppContext {
|
|||
appGroup: Constants.App.appGroupId,
|
||||
keychainLabel: Unlocalized.Keychain.passwordLabel,
|
||||
strategy: ProfileManager.CoreDataStrategy(
|
||||
persistence: persistenceManager.profilesPersistence(
|
||||
withName: Constants.Persistence.profilesContainerName
|
||||
)
|
||||
persistence: profilesPersistence
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -52,6 +52,14 @@ extension Constants {
|
|||
return "\(identifier).WireGuardTunnel"
|
||||
}
|
||||
}
|
||||
|
||||
static var isBeta: Bool {
|
||||
#if targetEnvironment(simulator)
|
||||
return true
|
||||
#else
|
||||
return Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
enum InApp {
|
||||
|
@ -67,7 +75,7 @@ extension Constants {
|
|||
|
||||
return testAppType
|
||||
}
|
||||
return isBeta ? .beta : .freemium
|
||||
return App.isBeta ? .beta : .freemium
|
||||
}
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
|
@ -87,14 +95,6 @@ extension Constants {
|
|||
return []
|
||||
}
|
||||
#endif
|
||||
|
||||
private static var isBeta: Bool {
|
||||
#if targetEnvironment(simulator)
|
||||
return true
|
||||
#else
|
||||
return Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,10 @@ extension OrganizerView {
|
|||
|
||||
@Binding var alertType: AlertType?
|
||||
|
||||
private var isTestBuild: Bool {
|
||||
Constants.App.isBeta
|
||||
}
|
||||
|
||||
private let redditURL = Constants.URLs.subreddit
|
||||
|
||||
private let shareMessage = L10n.Global.Messages.share
|
||||
|
@ -54,10 +58,12 @@ extension OrganizerView {
|
|||
Menu(L10n.Menu.All.Share.title) {
|
||||
shareMenu
|
||||
}
|
||||
if isTestBuild {
|
||||
Divider()
|
||||
testSection
|
||||
}
|
||||
Divider()
|
||||
aboutButton
|
||||
// RemoveVPNSection()
|
||||
// betaSection
|
||||
} label: {
|
||||
themeSettingsMenuImage.asSystemImage
|
||||
}
|
||||
|
@ -115,3 +121,14 @@ extension OrganizerView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension OrganizerView.SettingsMenu {
|
||||
private var testSection: some View {
|
||||
Button("Export providers") {
|
||||
guard let urls = AppContext.shared.urlsForProviders else {
|
||||
return
|
||||
}
|
||||
modalType = .exportProviders(urls)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ struct OrganizerView: View {
|
|||
|
||||
case about
|
||||
|
||||
case exportProviders([URL])
|
||||
|
||||
// XXX: alert ids
|
||||
var id: Int {
|
||||
switch self {
|
||||
|
@ -50,6 +52,8 @@ struct OrganizerView: View {
|
|||
case .share: return 5
|
||||
|
||||
case .about: return 6
|
||||
|
||||
case .exportProviders: return 7
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -157,6 +161,9 @@ extension OrganizerView {
|
|||
NavigationView {
|
||||
AboutView()
|
||||
}.themeGlobal()
|
||||
|
||||
case .exportProviders(let urls):
|
||||
ActivityView(activityItems: urls)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,17 @@ public class Persistence {
|
|||
}
|
||||
}
|
||||
|
||||
public var containerURLs: [URL]? {
|
||||
guard let url = container.persistentStoreDescriptions.first?.url else {
|
||||
return nil
|
||||
}
|
||||
return [
|
||||
url,
|
||||
url.deletingPathExtension().appendingPathExtension("sqlite-shm"),
|
||||
url.deletingPathExtension().appendingPathExtension("sqlite-wal")
|
||||
]
|
||||
}
|
||||
|
||||
// public func remoteChangesPublisher() -> AnyPublisher<Void, Never> {
|
||||
// NotificationCenter.default.publisher(
|
||||
// for: .NSPersistentStoreRemoteChange,
|
||||
|
|
Loading…
Reference in New Issue