-
Couldn't load subscription status.
- Fork 0
Sprint 10 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Sprint 10 #2
Conversation
| oauth2Service.fetchOAuthToken(code) { [weak self] result in | ||
| guard let self = self else { return } | ||
| switch result { | ||
| case .success: | ||
| self.switchToTabBarController() | ||
| case .failure: | ||
| print("failure fetchOAuthToken") | ||
| break | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Обычно именно ближе к UI части делают перевод на главную очередь, здесь это сделать удобнее, так как по сути только отобразить результат остается. Так ты избавишься от елочки в сервисе отправки запроса
| private func switchToTabBarController() { | ||
| guard let window = UIApplication.shared.windows.first else { fatalError("Invalid Configuration") } | ||
| let tabBarController = UIStoryboard(name: "Main", bundle: .main) | ||
| .instantiateViewController(withIdentifier: "TabBarViewController") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
хорошо бы делать консистентно: если где-то индификатор используется как константа, то и здесь можно также
| // @IBAction func clickExitButton(_ sender: Any) { | ||
| // | ||
| // } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
убрать, либо вернуть заглушку (@objc с таргетом на кнопку)
| import UIKit | ||
|
|
||
| final class SplashViewController: UIViewController { | ||
| private let ShowAuthenticationScreenSegueIdentifier = "ShowAuthenticationScreen" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется в прошлый раз уже говорила, что константы нужно именовывать в camelCase (ну либо единообразно по всему проекту)
| let path = "/oauth/token" | ||
| + "?client_id=\(AccessKey)" | ||
| + "&&client_secret=\(SecretKey)" | ||
| + "&&redirect_uri=\(RedirectURI)" | ||
| + "&&code=\(code)" | ||
| + "&&grant_type=authorization_code" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
здесь хорошо бы переписать на urlcomponents, потребуются path и queryItems
| return UserDefaults.standard.string(forKey: tokenKey) | ||
| } | ||
|
|
||
| set(newValue) { | ||
| if let token = newValue { | ||
| UserDefaults.standard.set(token, forKey: tokenKey) | ||
| } else { | ||
| UserDefaults.standard.removeObject(forKey: tokenKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UserDefaults.standard - повторяется три раза, можно завести приватную константу
|
|
||
| import Foundation | ||
|
|
||
| fileprivate let tokenKey = "BearerToken" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
обычно стараются избегать глобальных констант. Перенеси ее в класс либо сделай обертку
enum TokenStorageKeys {
case tokenKey = "BearerToken"
}
No description provided.