2020-07-31 23:40:57 +02:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Combine
|
2020-08-31 03:40:58 +02:00
|
|
|
import HTTP
|
2020-08-31 01:33:11 +02:00
|
|
|
import Mastodon
|
2020-08-31 20:57:02 +02:00
|
|
|
import MastodonStubs
|
|
|
|
import ServiceLayer
|
|
|
|
import ServiceLayerMocks
|
2020-07-31 23:40:57 +02:00
|
|
|
|
|
|
|
// swiftlint:disable force_try
|
2020-08-31 01:59:49 +02:00
|
|
|
private let decoder = APIDecoder()
|
2020-07-31 23:40:57 +02:00
|
|
|
private var cancellables = Set<AnyCancellable>()
|
2020-08-03 00:23:01 +02:00
|
|
|
private let devInstanceURL = URL(string: "https://mastodon.social")!
|
2020-08-08 01:19:13 +02:00
|
|
|
private let devIdentityID = UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!
|
2020-08-03 00:23:01 +02:00
|
|
|
private let devAccessToken = "DEVELOPMENT_ACCESS_TOKEN"
|
2020-07-31 23:40:57 +02:00
|
|
|
|
|
|
|
extension Account {
|
2020-08-31 20:57:02 +02:00
|
|
|
static let development = try! decoder.decode(Account.self,
|
|
|
|
from: AccountEndpoint.verifyCredentials.data(url: devInstanceURL)!)
|
2020-07-31 23:40:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extension Instance {
|
2020-08-31 20:57:02 +02:00
|
|
|
static let development = try! decoder.decode(Instance.self,
|
|
|
|
from: InstanceEndpoint.instance.data(url: devInstanceURL)!)
|
2020-07-31 23:40:57 +02:00
|
|
|
}
|
|
|
|
|
2020-08-03 00:23:01 +02:00
|
|
|
extension AppEnvironment {
|
2020-08-09 13:27:38 +02:00
|
|
|
static let development = AppEnvironment(
|
2020-08-12 09:24:39 +02:00
|
|
|
session: Session(configuration: .stubbing),
|
|
|
|
webAuthSessionType: SuccessfulMockWebAuthSession.self,
|
2020-08-18 07:13:37 +02:00
|
|
|
keychainServiceType: MockKeychainService.self,
|
|
|
|
userDefaults: MockUserDefaults(),
|
|
|
|
inMemoryContent: true)
|
2020-08-09 13:27:38 +02:00
|
|
|
}
|
|
|
|
|
2020-08-26 23:35:06 +02:00
|
|
|
extension AllIdentitiesService {
|
2020-08-31 12:21:01 +02:00
|
|
|
static let fresh = try! AllIdentitiesService(environment: .development)
|
|
|
|
|
|
|
|
static var development: Self = {
|
|
|
|
let allIdentitiesService = try! AllIdentitiesService(environment: .development)
|
|
|
|
|
|
|
|
allIdentitiesService.authorizeIdentity(id: devIdentityID, instanceURL: devInstanceURL)
|
|
|
|
.receive(on: ImmediateScheduler.shared)
|
|
|
|
.sink { _ in } receiveValue: { _ in }
|
|
|
|
.store(in: &cancellables)
|
|
|
|
|
|
|
|
// let identityService = try! allIdentitiesService.identityService(id: devIdentityID)
|
|
|
|
//
|
|
|
|
// identityService.verifyCredentials()
|
|
|
|
// .receive(on: ImmediateScheduler.shared)
|
|
|
|
// .sink { _ in } receiveValue: { _ in }
|
|
|
|
// .store(in: &cancellables)
|
|
|
|
//
|
|
|
|
// identityService.refreshInstance()
|
|
|
|
// .receive(on: ImmediateScheduler.shared)
|
|
|
|
// .sink { _ in } receiveValue: { _ in }
|
|
|
|
// .store(in: &cancellables)
|
|
|
|
|
|
|
|
return allIdentitiesService
|
|
|
|
} ()
|
2020-08-09 07:37:04 +02:00
|
|
|
}
|
|
|
|
|
2020-08-09 01:08:47 +02:00
|
|
|
extension IdentityService {
|
2020-08-26 23:35:06 +02:00
|
|
|
static let development = try! AllIdentitiesService.development.identityService(id: devIdentityID)
|
2020-08-08 08:01:45 +02:00
|
|
|
}
|
|
|
|
|
2020-08-13 12:18:21 +02:00
|
|
|
extension UserNotificationService {
|
|
|
|
static let development = UserNotificationService(userNotificationCenter: .current())
|
2020-08-12 09:24:39 +02:00
|
|
|
}
|
|
|
|
|
2020-08-03 17:20:51 +02:00
|
|
|
extension RootViewModel {
|
2020-08-12 09:24:39 +02:00
|
|
|
static let development = RootViewModel(
|
|
|
|
appDelegate: AppDelegate(),
|
2020-08-26 23:35:06 +02:00
|
|
|
allIdentitiesService: .development,
|
2020-08-13 12:18:21 +02:00
|
|
|
userNotificationService: .development)
|
2020-08-09 07:37:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extension AddIdentityViewModel {
|
|
|
|
static let development = RootViewModel.development.addIdentityViewModel()
|
2020-08-03 17:20:51 +02:00
|
|
|
}
|
|
|
|
|
2020-08-27 06:25:28 +02:00
|
|
|
extension TabNavigationViewModel {
|
|
|
|
static let development = RootViewModel.development.tabNavigationViewModel!
|
2020-08-03 17:20:51 +02:00
|
|
|
}
|
|
|
|
|
2020-08-07 05:57:52 +02:00
|
|
|
extension SecondaryNavigationViewModel {
|
2020-08-27 06:25:28 +02:00
|
|
|
static let development = TabNavigationViewModel.development.secondaryNavigationViewModel()
|
2020-07-31 23:40:57 +02:00
|
|
|
}
|
|
|
|
|
2020-08-04 22:26:09 +02:00
|
|
|
extension IdentitiesViewModel {
|
2020-08-09 01:08:47 +02:00
|
|
|
static let development = IdentitiesViewModel(identityService: .development)
|
2020-08-04 22:26:09 +02:00
|
|
|
}
|
|
|
|
|
2020-08-29 05:50:58 +02:00
|
|
|
extension ListsViewModel {
|
|
|
|
static let development = ListsViewModel(identityService: .development)
|
|
|
|
}
|
|
|
|
|
2020-08-07 12:59:48 +02:00
|
|
|
extension PreferencesViewModel {
|
2020-08-09 01:08:47 +02:00
|
|
|
static let development = PreferencesViewModel(identityService: .development)
|
2020-08-07 12:59:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extension PostingReadingPreferencesViewModel {
|
2020-08-09 01:08:47 +02:00
|
|
|
static let development = PostingReadingPreferencesViewModel(identityService: .development)
|
2020-08-07 12:14:14 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 23:41:55 +02:00
|
|
|
extension NotificationTypesPreferencesViewModel {
|
|
|
|
static let development = NotificationTypesPreferencesViewModel(identityService: .development)
|
|
|
|
}
|
|
|
|
|
2020-08-29 12:26:26 +02:00
|
|
|
extension FiltersViewModel {
|
|
|
|
static let development = FiltersViewModel(identityService: .development)
|
|
|
|
}
|
|
|
|
|
|
|
|
extension EditFilterViewModel {
|
2020-08-31 01:33:11 +02:00
|
|
|
static let development = EditFilterViewModel(filter: Filter.new, identityService: .development)
|
2020-08-29 12:26:26 +02:00
|
|
|
}
|
|
|
|
|
2020-08-26 23:20:44 +02:00
|
|
|
extension StatusListViewModel {
|
2020-08-26 23:35:06 +02:00
|
|
|
static let development = StatusListViewModel(
|
|
|
|
statusListService: IdentityService.development.service(timeline: .home))
|
2020-08-18 07:13:37 +02:00
|
|
|
}
|
|
|
|
|
2020-07-31 23:40:57 +02:00
|
|
|
// swiftlint:enable force_try
|