Skip to content

Commit

Permalink
Merge pull request #25 from MuShare/fix/init-state
Browse files Browse the repository at this point in the history
Init pluto state by token
  • Loading branch information
lm2343635 authored Oct 24, 2020
2 parents a45b3ab + d101d9a commit baa7eaf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
18 changes: 9 additions & 9 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
PODS:
- Alamofire (5.2.2)
- Kingfisher (5.15.2):
- Kingfisher/Core (= 5.15.2)
- Kingfisher/Core (5.15.2)
- PlutoSDK/Core (0.8.3):
- Alamofire (5.3.0)
- Kingfisher (5.15.6):
- Kingfisher/Core (= 5.15.6)
- Kingfisher/Core (5.15.6)
- PlutoSDK/Core (0.8.4):
- Alamofire (~> 5)
- SwiftyJSON (~> 5)
- SwiftyUserDefaults (~> 5)
- PlutoSDK/Rx (0.8.3):
- PlutoSDK/Rx (0.8.4):
- PlutoSDK/Core (~> 0)
- RxCocoa (~> 5)
- RxCocoa (5.1.1):
Expand Down Expand Up @@ -38,9 +38,9 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
Alamofire: 814429acc853c6c54ff123fc3d2ef66803823ce0
Kingfisher: 1f60394409c6b916ce31474bcf73fdde6f3b9a7b
PlutoSDK: 0b10a6d9c0289f0cecc6169d592a258cf4443eb7
Alamofire: 2c792affbdc2f18016e08fdbcacd60aebe1ba593
Kingfisher: b3554e7bf6106115b44e8795300bad580ef2fdc7
PlutoSDK: 4d156962bbd58309a9eb2652bb7b3368caf4e082
RxCocoa: 32065309a38d29b5b0db858819b5bf9ef038b601
RxRelay: d77f7d771495f43c556cbc43eebd1bb54d01e8e9
RxSwift: 81470a2074fa8780320ea5fe4102807cb7118178
Expand Down
7 changes: 5 additions & 2 deletions Pluto/Classes/Core/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ class DefaultsManager {
)
}
)

}

var isTokenNil: Bool {
accessToken == nil || refreshToken == nil
}

func updateAccessToken(_ accessToken: String) -> Bool {
Expand All @@ -132,5 +135,5 @@ class DefaultsManager {
sub = nil
infoJSONString = nil
}

}
10 changes: 1 addition & 9 deletions Pluto/Classes/Core/Pluto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final public class Pluto {
var isWeChatInstalled = false

var stateObserver: ((State) -> Void)?
var state: State = .loading {
var state: State = DefaultsManager.shared.isTokenNil ? .notSignin : .signin {
didSet {
stateObserver?(state)
}
Expand Down Expand Up @@ -82,14 +82,6 @@ final public class Pluto {
self.server = server
self.appId = appId
self.isWeChatInstalled = isWeChatInstalled

getAccessToken { [unowned self] in
guard $0 != nil else {
self.state = .notSignin
return
}
self.state = .signin
}
}

public func observeState(observer: ((State) -> Void)?) {
Expand Down
2 changes: 1 addition & 1 deletion PlutoSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'PlutoSDK'
s.version = '0.8.3'
s.version = '0.8.4'
s.summary = 'Swift SDK for Pluto login microservice.'

# This description is used to generate tags and improve search results.
Expand Down

0 comments on commit baa7eaf

Please sign in to comment.