2022-04-27 11:37:03 +02:00
|
|
|
//
|
|
|
|
// MastodonServerRulesViewController+Debug.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-4-27.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
2022-10-08 07:43:06 +02:00
|
|
|
import MastodonCore
|
2022-04-27 11:37:03 +02:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
|
|
|
extension MastodonRegisterViewController {
|
|
|
|
|
|
|
|
@MainActor
|
|
|
|
static func create(
|
|
|
|
context: AppContext,
|
|
|
|
coordinator: SceneCoordinator,
|
|
|
|
domain: String
|
|
|
|
) async throws -> MastodonRegisterViewController {
|
|
|
|
let viewController = MastodonRegisterViewController()
|
|
|
|
viewController.context = context
|
|
|
|
viewController.coordinator = coordinator
|
|
|
|
|
|
|
|
let instanceResponse = try await context.apiService.instance(domain: domain).singleOutput()
|
|
|
|
let applicationResponse = try await context.apiService.createApplication(domain: domain).singleOutput()
|
|
|
|
let accessTokenResponse = try await context.apiService.applicationAccessToken(
|
|
|
|
domain: domain,
|
|
|
|
clientID: applicationResponse.value.clientID!,
|
|
|
|
clientSecret: applicationResponse.value.clientSecret!,
|
|
|
|
redirectURI: applicationResponse.value.redirectURI!
|
|
|
|
).singleOutput()
|
|
|
|
|
|
|
|
viewController.viewModel = MastodonRegisterViewModel(
|
|
|
|
context: context,
|
|
|
|
domain: domain,
|
|
|
|
authenticateInfo: .init(
|
|
|
|
domain: domain,
|
|
|
|
application: applicationResponse.value
|
|
|
|
)!,
|
|
|
|
instance: instanceResponse.value,
|
|
|
|
applicationToken: accessTokenResponse.value
|
|
|
|
)
|
|
|
|
|
|
|
|
return viewController
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|