Skip to content

Commit cf6d1c4

Browse files
committed
AuthenticatedState: New Convenience Initializer
1 parent 41bbfdb commit cf6d1c4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

WooCommerce/Classes/Yosemite/AuthenticatedState.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import Networking
99
//
1010
class AuthenticatedState: StoresManagerState {
1111

12-
/// Active Credentials
13-
///
14-
private let credentials: Credentials
15-
1612
/// Dispatcher: Glues all of the Stores!
1713
///
1814
private let dispatcher = Dispatcher()
@@ -32,8 +28,16 @@ class AuthenticatedState: StoresManagerState {
3228
AccountStore(dispatcher: dispatcher, storageManager: storageManager, network: network),
3329
OrderStore(dispatcher: dispatcher, storageManager: storageManager, network: network)
3430
]
31+
}
32+
33+
/// Convenience Initializer
34+
///
35+
convenience init?(sessionManager: SessionManager) {
36+
guard let credentials = sessionManager.defaultCredentials else {
37+
return nil
38+
}
3539

36-
self.credentials = credentials
40+
self.init(credentials: credentials)
3741
}
3842

3943

0 commit comments

Comments
 (0)