Skip to content

Commit cb16ee3

Browse files
authored
Use new login API (#178)
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
1 parent 0c8a12f commit cb16ee3

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

.swiftlint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,9 @@ large_tuple:
4040
warning: 4
4141
error: 6
4242

43+
type_body_length:
44+
warning: 300
45+
error: 400
46+
4347
switch_case_alignment:
4448
indented_cases: true

iOCNotes/Store.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,7 @@ final class Store: Logging, Storing {
297297
KeychainHelper.syncOnStart = newValue
298298
}
299299
}
300-
}
301-
302-
// MARK: - ServerAddressViewDelegate
303300

304-
extension Store: ServerAddressViewDelegate {
305301
private func getResponse(endpoint: URL, token: String, options: NKRequestOptions) async -> (url: String, user: String, appPassword: String)? {
306302
logger.debug("Getting login flow status...")
307303

iOCNotes/Views/ContentView.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,18 @@ struct ContentView: View {
3535

3636
var body: some View {
3737
if store.accounts.isEmpty {
38-
ServerAddressView(backgroundColor: .constant(Color.accent), brandImage: Image("BrandLogo"), delegate: store, sharedAccounts: sharedAccounts, userAgent: userAgent)
39-
.onAppear {
40-
// The store must update its list of shared accounts when the login user interface is about to appear.
41-
store.readSharedAccounts()
42-
}
38+
ServerAddressView(backgroundColor: .constant(Color.accent), brandImage: Image("BrandLogo"), sharedAccounts: sharedAccounts, userAgent: userAgent) { host, name, password in
39+
store.addAccount(host: host, name: name, password: password)
40+
} beginPolling: { url, _ in
41+
try await store.beginPolling(at: url)
42+
} cancelPolling: { token in
43+
store.cancelPolling(by: token)
44+
}
45+
.onAppear {
46+
// The store must update its list of shared accounts when the login user interface is about to appear.
47+
store.readSharedAccounts()
48+
}
49+
4350
} else {
4451
TabView(selection: $selection) {
4552
NavigationStack {

0 commit comments

Comments
 (0)