2020-08-02 22:23:01 +00:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
2020-09-03 03:28:34 +00:00
|
|
|
import DB
|
2020-08-02 22:23:01 +00:00
|
|
|
import Foundation
|
2020-08-31 01:40:58 +00:00
|
|
|
import HTTP
|
2020-09-04 00:54:05 +00:00
|
|
|
import Keychain
|
2020-08-30 23:33:11 +00:00
|
|
|
import Mastodon
|
2020-09-01 07:33:49 +00:00
|
|
|
import UserNotifications
|
2020-08-02 22:23:01 +00:00
|
|
|
|
2020-08-31 10:21:01 +00:00
|
|
|
public struct AppEnvironment {
|
2020-09-23 07:04:37 +00:00
|
|
|
let session: URLSession
|
2020-08-12 09:01:21 +00:00
|
|
|
let webAuthSessionType: WebAuthSession.Type
|
2020-09-04 00:54:05 +00:00
|
|
|
let keychain: Keychain.Type
|
2020-08-18 05:13:37 +00:00
|
|
|
let userDefaults: UserDefaults
|
2020-09-01 07:33:49 +00:00
|
|
|
let userNotificationClient: UserNotificationClient
|
2020-09-13 00:50:22 +00:00
|
|
|
let uuid: () -> UUID
|
2020-08-18 05:13:37 +00:00
|
|
|
let inMemoryContent: Bool
|
2020-09-08 02:12:38 +00:00
|
|
|
let fixtureDatabase: IdentityDatabase?
|
2020-08-31 10:21:01 +00:00
|
|
|
|
2020-09-23 07:04:37 +00:00
|
|
|
public init(session: URLSession,
|
2020-08-31 10:21:01 +00:00
|
|
|
webAuthSessionType: WebAuthSession.Type,
|
2020-09-04 00:54:05 +00:00
|
|
|
keychain: Keychain.Type,
|
2020-08-31 10:21:01 +00:00
|
|
|
userDefaults: UserDefaults,
|
2020-09-01 07:33:49 +00:00
|
|
|
userNotificationClient: UserNotificationClient,
|
2020-09-13 00:50:22 +00:00
|
|
|
uuid: @escaping () -> UUID,
|
2020-09-01 07:33:49 +00:00
|
|
|
inMemoryContent: Bool,
|
2020-09-08 02:12:38 +00:00
|
|
|
fixtureDatabase: IdentityDatabase?) {
|
2020-08-31 10:21:01 +00:00
|
|
|
self.session = session
|
|
|
|
self.webAuthSessionType = webAuthSessionType
|
2020-09-04 00:54:05 +00:00
|
|
|
self.keychain = keychain
|
2020-08-31 10:21:01 +00:00
|
|
|
self.userDefaults = userDefaults
|
2020-09-01 07:33:49 +00:00
|
|
|
self.userNotificationClient = userNotificationClient
|
2020-09-13 00:50:22 +00:00
|
|
|
self.uuid = uuid
|
2020-08-31 10:21:01 +00:00
|
|
|
self.inMemoryContent = inMemoryContent
|
2020-09-08 02:12:38 +00:00
|
|
|
self.fixtureDatabase = fixtureDatabase
|
2020-08-31 10:21:01 +00:00
|
|
|
}
|
2020-08-12 07:24:39 +00:00
|
|
|
}
|
|
|
|
|
2020-08-31 10:21:01 +00:00
|
|
|
public extension AppEnvironment {
|
2020-09-01 07:33:49 +00:00
|
|
|
static func live(userNotificationCenter: UNUserNotificationCenter) -> Self {
|
|
|
|
Self(
|
2020-09-23 07:04:37 +00:00
|
|
|
session: URLSession.shared,
|
2020-09-01 07:33:49 +00:00
|
|
|
webAuthSessionType: LiveWebAuthSession.self,
|
2020-09-04 00:54:05 +00:00
|
|
|
keychain: LiveKeychain.self,
|
2020-09-01 07:33:49 +00:00
|
|
|
userDefaults: .standard,
|
|
|
|
userNotificationClient: .live(userNotificationCenter),
|
2020-09-13 00:50:22 +00:00
|
|
|
uuid: UUID.init,
|
2020-09-01 07:33:49 +00:00
|
|
|
inMemoryContent: false,
|
2020-09-08 02:12:38 +00:00
|
|
|
fixtureDatabase: nil)
|
2020-09-01 07:33:49 +00:00
|
|
|
}
|
2020-08-02 22:23:01 +00:00
|
|
|
}
|