Slash some todos (#540)

This commit is contained in:
Nathan Mattes 2022-11-14 17:53:37 +01:00
parent 105a98a395
commit 082e0933d2
3 changed files with 29 additions and 30 deletions

View File

@ -548,6 +548,6 @@ extension SceneCoordinator: MastodonLoginViewControllerDelegate {
} }
func nextButtonPressed(_ viewController: MastodonLoginViewController) { func nextButtonPressed(_ viewController: MastodonLoginViewController) {
//TODO: @zeitschlag implement, show ASWebAuthentication and stuff viewController.login()
} }
} }

View File

@ -133,35 +133,34 @@ class MastodonLoginViewController: UIViewController, NeedsDependency {
} }
@objc func nextButtonPressed(_ sender: Any) { @objc func nextButtonPressed(_ sender: Any) {
login(sender) delegate?.nextButtonPressed(self)
} }
@objc func login(_ sender: Any) { @objc func login() {
guard let server = viewModel.selectedServer else { return } guard let server = viewModel.selectedServer else { return }
authenticationViewModel authenticationViewModel
.authenticated .authenticated
.asyncMap { domain, user -> Result<Bool, Error> in .asyncMap { domain, user -> Result<Bool, Error> in
do { do {
let result = try await self.context.authenticationService.activeMastodonUser(domain: domain, userID: user.id) let result = try await self.context.authenticationService.activeMastodonUser(domain: domain, userID: user.id)
return .success(result) return .success(result)
} catch { } catch {
return .failure(error) return .failure(error)
}
} }
.receive(on: DispatchQueue.main) }
.sink { [weak self] result in .receive(on: DispatchQueue.main)
guard let self = self else { return } .sink { [weak self] result in
switch result { guard let self = self else { return }
case .failure(let error): switch result {
assertionFailure(error.localizedDescription) case .failure(let error):
case .success(let isActived): assertionFailure(error.localizedDescription)
assert(isActived) case .success(let isActived):
// self.dismiss(animated: true, completion: nil) assert(isActived)
self.coordinator.setup() self.coordinator.setup()
}
} }
.store(in: &disposeBag) }
.store(in: &disposeBag)
authenticationViewModel.isAuthenticating.send(true) authenticationViewModel.isAuthenticating.send(true)
context.apiService.createApplication(domain: server.domain) context.apiService.createApplication(domain: server.domain)
@ -183,9 +182,10 @@ class MastodonLoginViewController: UIViewController, NeedsDependency {
switch completion { switch completion {
case .failure(let error): case .failure(let error):
//TODO: @zeitschlag show error let alert = UIAlertController.standardAlert(of: error)
break self.present(alert, animated: true)
case .finished: case .finished:
// do nothing. There's a subscriber above resulting in `coordinator.setup()`
break break
} }
} receiveValue: { [weak self] info in } receiveValue: { [weak self] info in
@ -251,7 +251,6 @@ class MastodonLoginViewController: UIViewController, NeedsDependency {
self.view.layoutIfNeeded() self.view.layoutIfNeeded()
} }
} }
} }
// MARK: - OnboardingViewControllerAppearance // MARK: - OnboardingViewControllerAppearance
@ -290,7 +289,7 @@ extension MastodonLoginViewController: MastodonLoginViewModelDelegate {
// MARK: - ASWebAuthenticationPresentationContextProviding // MARK: - ASWebAuthenticationPresentationContextProviding
extension MastodonLoginViewController: ASWebAuthenticationPresentationContextProviding { extension MastodonLoginViewController: ASWebAuthenticationPresentationContextProviding {
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor { func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
return view.window! return view.window!
} }
} }

View File

@ -317,7 +317,7 @@ uploaded to Mastodon.";
"Scene.Register.LetsGetYouSetUpOnDomain" = "Lets get you set up on %@"; "Scene.Register.LetsGetYouSetUpOnDomain" = "Lets get you set up on %@";
"Scene.Login.Title" = "Welcome Back!"; "Scene.Login.Title" = "Welcome Back!";
"Scene.Login.Subtitle" = "Log you in with the server where you created your account"; "Scene.Login.Subtitle" = "Log you in with the server where you created your account";
"Scene.Login.ServerSearchField.Placeholder" = "Search for your server"; "Scene.Login.ServerSearchField.Placeholder" = "Search server or enter URL";
"Scene.Register.Title" = "Lets get you set up on %@"; "Scene.Register.Title" = "Lets get you set up on %@";
"Scene.Report.Content1" = "Are there any other posts youd like to add to the report?"; "Scene.Report.Content1" = "Are there any other posts youd like to add to the report?";
"Scene.Report.Content2" = "Is there anything the moderators should know about this report?"; "Scene.Report.Content2" = "Is there anything the moderators should know about this report?";