Skip to content

Commit fb865ee

Browse files
committed
AccountStore: Handling AccountAction.loadAccount
1 parent 4b7f913 commit fb865ee

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Yosemite/Yosemite/Stores/AccountStore.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class AccountStore: Store {
2525
switch action {
2626
case .synchronizeAccount(let onCompletion):
2727
synchronizeAccount(onCompletion: onCompletion)
28+
case .loadAccount(let userID, let onCompletion):
29+
loadAccount(userID: userID, onCompletion: onCompletion)
2830
}
2931
}
3032
}
@@ -49,6 +51,13 @@ extension AccountStore {
4951
onCompletion(account, nil)
5052
}
5153
}
54+
55+
/// Loads the Account associated with the specified userID (if any!).
56+
///
57+
func loadAccount(userID: Int, onCompletion: @escaping (Account?) -> Void) {
58+
let account = loadStoredAccount(userId: userID)?.toReadOnly()
59+
onCompletion(account)
60+
}
5261
}
5362

5463

0 commit comments

Comments
 (0)