Skip to content

Commit

Permalink
Will now sync the catalog and notify user change when logged in with …
Browse files Browse the repository at this point in the history
…passkey or suomi.fi
  • Loading branch information
Kaappihullu committed Mar 28, 2024
1 parent f446885 commit 824b6b1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 50 deletions.
6 changes: 0 additions & 6 deletions Palace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,6 @@
3688FADE2B67FEFE00A95558 /* EkirjastoLoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3688FADD2B67FEFE00A95558 /* EkirjastoLoginViewController.swift */; };
3688FADF2B67FEFE00A95558 /* EkirjastoLoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3688FADD2B67FEFE00A95558 /* EkirjastoLoginViewController.swift */; };
3688FAE12B67FEFE00A95558 /* EkirjastoLoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3688FADD2B67FEFE00A95558 /* EkirjastoLoginViewController.swift */; };
3689CAB82BA0B0310010B598 /* NavigationConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3689CAB72BA0B0310010B598 /* NavigationConfigurator.swift */; };
3689CAB92BA0B0310010B598 /* NavigationConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3689CAB72BA0B0310010B598 /* NavigationConfigurator.swift */; };
368B2AA82BAD7B4D00A14D2E /* TPPSignInBusinessLogic+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 368B2AA72BAD7B4D00A14D2E /* TPPSignInBusinessLogic+Extensions.swift */; };
368B2AA92BAD7B4D00A14D2E /* TPPSignInBusinessLogic+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 368B2AA72BAD7B4D00A14D2E /* TPPSignInBusinessLogic+Extensions.swift */; };
368B2AAA2BAD7B4D00A14D2E /* TPPSignInBusinessLogic+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 368B2AA72BAD7B4D00A14D2E /* TPPSignInBusinessLogic+Extensions.swift */; };
Expand Down Expand Up @@ -1745,7 +1743,6 @@
363C62092B14EEA300858AA5 /* EkirjastoUserLoginView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EkirjastoUserLoginView.swift; sourceTree = "<group>"; };
36833E4B2B5E937000D7B6B2 /* PasskeyManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasskeyManager.swift; sourceTree = "<group>"; };
3688FADD2B67FEFE00A95558 /* EkirjastoLoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EkirjastoLoginViewController.swift; sourceTree = "<group>"; };
3689CAB72BA0B0310010B598 /* NavigationConfigurator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationConfigurator.swift; sourceTree = "<group>"; };
368B2AA72BAD7B4D00A14D2E /* TPPSignInBusinessLogic+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TPPSignInBusinessLogic+Extensions.swift"; sourceTree = "<group>"; };
52545184217A76FF00BBC1B4 /* TPPUserNotifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TPPUserNotifications.swift; sourceTree = "<group>"; };
52592BB721220A1100587288 /* TPPLocalization.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TPPLocalization.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3507,7 +3504,6 @@
E5FFB96628AED70E0042907F /* ActivityIndicator.swift */,
E5FFB9CA28AFE8AF0042907F /* AsyncImage.swift */,
E523A452299FCA5300EF833B /* AlertModel.swift */,
3689CAB72BA0B0310010B598 /* NavigationConfigurator.swift */,
);
path = SwiftUI;
sourceTree = "<group>";
Expand Down Expand Up @@ -4722,7 +4718,6 @@
331263E82A287F53006BA87D /* TPPBookRegistry+Extensions.swift in Sources */,
331263E92A287F53006BA87D /* TPPIndeterminateProgressView.m in Sources */,
331263EA2A287F53006BA87D /* NSString+TPPStringAdditions.m in Sources */,
3689CAB92BA0B0310010B598 /* NavigationConfigurator.swift in Sources */,
331263EC2A287F53006BA87D /* TPPRequestExecuting.swift in Sources */,
331263ED2A287F53006BA87D /* TPPCookiesWebViewController.swift in Sources */,
331263EE2A287F53006BA87D /* TPPSamlIDPCell.swift in Sources */,
Expand Down Expand Up @@ -5195,7 +5190,6 @@
085640CE1BB99FC30088BDBF /* NSURL+NYPLURLAdditions.m in Sources */,
1183F35B194F847100DC322F /* TPPAsync.m in Sources */,
E52E3C0928C19BAD0073DC4D /* SamplePlayerError.swift in Sources */,
3689CAB82BA0B0310010B598 /* NavigationConfigurator.swift in Sources */,
11B20E6E19D9F6DD00877A23 /* TPPReloadView.m in Sources */,
E694040A1E4A789800E566ED /* TPPReachabilityManager.m in Sources */,
A4BA1D0E1B430341006F83DF /* TPPCatalogGroupedFeedViewController.m in Sources */,
Expand Down
5 changes: 3 additions & 2 deletions Palace/Book/Models/TPPBookRegistry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class TPPBookRegistry: NSObject, TPPBookRegistrySyncing {
/// Synchronizes local registry data and current loans data.
/// - Parameter completion: Completion handler provides an error document for error handling and a boolean value, indicating the presence of books available for download.
func sync(completion: ((_ errorDocument: [AnyHashable: Any]?, _ newBooks: Bool) -> Void)? = nil) {

guard let loansUrl = AccountsManager.shared.currentAccount?.loansUrl else {
return
}
Expand All @@ -233,14 +234,14 @@ class TPPBookRegistry: NSObject, TPPBookRegistrySyncing {
}
state = .syncing
syncUrl = loansUrl
print("book registry syncUrl: \(syncUrl)")
print("book registry syncUrl 1: \(syncUrl)")
TPPOPDSFeed.withURL(loansUrl, shouldResetCache: true) { feed, errorDocument in
print("book registry withURL!")
DispatchQueue.main.async {
defer {
self.state = .loaded
self.syncUrl = nil
print("book registry syncUrl: \(self.syncUrl)")
print("book registry syncUrl 2: \(self.syncUrl)")
}
if self.syncUrl != loansUrl {
return
Expand Down
7 changes: 7 additions & 0 deletions Palace/Network/TPPNetworkExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,14 @@ extension TPPNetworkExecutor {

if let accessToken = accessToken {
let sharedAccount = TPPUserAccount.sharedAccount()

sharedAccount.setAuthToken(accessToken,barcode: nil, pin: nil, expirationDate: nil)

//is it ok to have a direct reference to TPPSignInBusinessLogic here?
TPPSignInBusinessLogic.getShared { logic in
logic?.notifySignIn()
}

}else{
print("authenticateWithToken error: \(String(describing: error?.localizedDescription)) data: \(String(describing: String(data:data!,encoding: .utf8)))")
}
Expand Down
33 changes: 0 additions & 33 deletions Palace/Utilities/SwiftUI/NavigationConfigurator.swift

This file was deleted.

17 changes: 8 additions & 9 deletions Palace/Utilities/TPPSignInBusinessLogic+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,20 @@ extension TPPSignInBusinessLogic {

AccountsManager.shared.onAccountsHaveLoaded {
let account = AccountsManager.shared.accounts().first!
/*initWithLibraryAccountID:libraryUUID
libraryAccountsProvider:AccountsManager.shared
urlSettingsProvider: TPPSettings.shared
bookRegistry:[TPPBookRegistry shared]
bookDownloadsCenter:[MyBooksDownloadCenter shared]
userAccountProvider:[TPPUserAccount class]
uiDelegate:self
drmAuthorizer:drmAuthorizer];*/
shared = TPPSignInBusinessLogic(libraryAccountID: account.uuid, libraryAccountsProvider: AccountsManager.shared, urlSettingsProvider: TPPSettings.shared, bookRegistry: TPPBookRegistry.shared as! TPPBookRegistrySyncing, bookDownloadsCenter: MyBooksDownloadCenter.shared, userAccountProvider: TPPUserAccount.self, uiDelegate: nil, drmAuthorizer: nil)

shared = TPPSignInBusinessLogic(libraryAccountID: account.uuid, libraryAccountsProvider: AccountsManager.shared, urlSettingsProvider: TPPSettings.shared, bookRegistry: TPPBookRegistry.shared as TPPBookRegistrySyncing, bookDownloadsCenter: MyBooksDownloadCenter.shared, userAccountProvider: TPPUserAccount.self, uiDelegate: nil, drmAuthorizer: nil)
completion(shared)
}


}

public func notifySignIn(){
if libraryAccountID == libraryAccountsProvider.currentAccountId {
bookRegistry.sync()
}

NotificationCenter.default.post(name: .TPPIsSigningIn, object: false)
}

}

0 comments on commit 824b6b1

Please sign in to comment.