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