diff --git a/App/client-ios.xcodeproj/project.pbxproj b/App/client-ios.xcodeproj/project.pbxproj index 7985bef1ddb34bbb1b13cec4bf779876e51855a7..a3615f3201af5b3a10ab768fcd6283c37af38c1f 100644 --- a/App/client-ios.xcodeproj/project.pbxproj +++ b/App/client-ios.xcodeproj/project.pbxproj @@ -448,7 +448,7 @@ CODE_SIGN_ENTITLEMENTS = "client-ios/Resources/client-ios.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 256; + CURRENT_PROJECT_VERSION = 259; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = S6JDM2WW29; ENABLE_BITCODE = NO; @@ -487,7 +487,7 @@ CODE_SIGN_ENTITLEMENTS = "client-ios/Resources/client-ios.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 256; + CURRENT_PROJECT_VERSION = 259; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = S6JDM2WW29; ENABLE_BITCODE = NO; @@ -522,7 +522,7 @@ CODE_SIGN_ENTITLEMENTS = NotificationExtension/NotificationExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 256; + CURRENT_PROJECT_VERSION = 259; DEVELOPMENT_TEAM = S6JDM2WW29; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -553,7 +553,7 @@ CODE_SIGN_ENTITLEMENTS = NotificationExtension/NotificationExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 256; + CURRENT_PROJECT_VERSION = 259; DEVELOPMENT_TEAM = S6JDM2WW29; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/Package.swift b/Package.swift index c00b4df2d81f0a9e5fc62ea5b580af5e94074a2b..c7012b91b7ea7166428d28193ca4e0c1d2e12ff6 100644 --- a/Package.swift +++ b/Package.swift @@ -115,9 +115,9 @@ let package = Package( .upToNextMajor(from: "1.6.0") ), .package( - path: "../elixxir-dapps-sdk-swift" -// url: "https://git.xx.network/elixxir/elixxir-dapps-sdk-swift", -// branch: "feature/messenger-restore-from-backup" +// path: "../elixxir-dapps-sdk-swift" + url: "https://git.xx.network/elixxir/elixxir-dapps-sdk-swift", + branch: "development" ), .package( url: "https://git.xx.network/elixxir/client-ios-db.git", diff --git a/Sources/BackupFeature/Service/BackupService.swift b/Sources/BackupFeature/Service/BackupService.swift index f0fcaf7e46b302507ac6a85613c28554dcc323e9..788fd7d454ff95f4614ce7e49d4a381af4761596 100644 --- a/Sources/BackupFeature/Service/BackupService.swift +++ b/Sources/BackupFeature/Service/BackupService.swift @@ -86,10 +86,10 @@ extension BackupService { ) ) + print(">>> Will addJSON: \(String(data: currentFacts, encoding: .utf8)!)") manager.addJSON(String(data: currentFacts, encoding: .utf8)!) } - guard settings.value.automaticBackups == true else { return } performBackup() } @@ -99,6 +99,8 @@ extension BackupService { } public func performBackup() { + print(">>> Did call performBackup()") + guard let directoryUrl = try? FileManager.default.url( for: .applicationSupportDirectory, in: .userDomainMask, @@ -119,6 +121,8 @@ extension BackupService { } public func updateBackup(data: Data) { + print(">>> Did call updateBackup(data)") + guard let directoryUrl = try? FileManager.default.url( for: .applicationSupportDirectory, in: .userDomainMask, @@ -306,6 +310,8 @@ extension BackupService { } private func performBackup(data: Data) { + print(">>> Did call performBackup(data)") + guard let enabledService = settings.value.enabledService else { fatalError("Trying to backup but nothing is enabled") } @@ -316,7 +322,7 @@ extension BackupService { do { try data.write(to: url, options: .atomic) } catch { - print("Couldn't write to temp: \(error.localizedDescription)") + print(">>> Couldn't write to temp: \(error.localizedDescription)") return } diff --git a/Sources/BackupFeature/ViewModels/BackupConfigViewModel.swift b/Sources/BackupFeature/ViewModels/BackupConfigViewModel.swift index 757f3046d1f8c51611fdff1f5af403f6006d95cc..4b398f9028bf284019a1155ef4e1f0011dab165a 100644 --- a/Sources/BackupFeature/ViewModels/BackupConfigViewModel.swift +++ b/Sources/BackupFeature/ViewModels/BackupConfigViewModel.swift @@ -68,14 +68,9 @@ extension BackupConfigViewModel { context.service.toggle(service: service, enabling: false) }, passphraseClosure: { passphrase in context.hud.update(with: .onTitle("Initializing and securing your backup file will take few seconds, please keep the app open.")) - DispatchQueue.global().async { - context.service.toggle(service: service, enabling: enabling) - context.service.initializeBackup(passphrase: passphrase) - - DispatchQueue.main.async { - context.hud.update(with: .none) - } - } + context.service.toggle(service: service, enabling: enabling) + context.service.initializeBackup(passphrase: passphrase) + context.hud.update(with: .none) }) }, didTapService: context.service.authorize, diff --git a/Sources/LaunchFeature/LaunchViewModel.swift b/Sources/LaunchFeature/LaunchViewModel.swift index ad65cc9ea3b229fd0be9aa23326f9ff8a8b89c1d..fb6f56c3c9aa472a6fa12b1d7867b0f30728be85 100644 --- a/Sources/LaunchFeature/LaunchViewModel.swift +++ b/Sources/LaunchFeature/LaunchViewModel.swift @@ -140,6 +140,7 @@ final class LaunchViewModel { hudSubject.send(.none) routeSubject.send(.chats) } else { + dropboxService.unlink() hudSubject.send(.none) routeSubject.send(.onboarding) } @@ -159,7 +160,6 @@ final class LaunchViewModel { private func cleanUp() { // try? cMixManager.remove() // try? keychainHandler.clear() -// dropboxService.unlink() } private func presentOnboardingFlow() { @@ -534,7 +534,7 @@ extension LaunchViewModel { return } - guard let members = try? group.getMembership(), let leader = members.first else { + guard var members = try? group.getMembership(), let leader = members.first else { fatalError("Failed to get group membership/leader") } @@ -560,13 +560,42 @@ extension LaunchViewModel { )) } - let friends = try! database.fetchContacts(.init(id: Set(members.map(\.id)))) - let strangers = members.filter { !friends.map(\.id).contains($0.id) } + print(">>> All members in the arrived group request:") + members.forEach { print(">>> \($0.id.base64EncodedString().prefix(10))...") } + print(">>> My ud.id is: \(try! messenger.ud.get()!.getContact().getId().base64EncodedString().prefix(10))...") + print(">>> My e2e.id is: \(try! messenger.e2e.get()!.getContact().getId().base64EncodedString().prefix(10))...") + + let friends = try! database.fetchContacts(.init( + id: Set(members.map(\.id)), + authStatus: [ + .friend, + .hidden, + .requesting, + .confirming, + .verificationInProgress, + .verified, + .requested, + .requestFailed, + .verificationFailed, + .confirmationFailed + ] + )) + + print(">>> These people I already know:") + friends.forEach { + print(">>> Username: \($0.username), authStatus: \($0.authStatus.rawValue), id: \($0.id.base64EncodedString().prefix(10))...") + } + + let strangers = Set(members.map(\.id)).subtracting(Set(friends.map(\.id))) + + strangers.forEach { + if let stranger = try? database.fetchContacts(.init(id: [$0])).first { + print(">>> This is a stranger, but I already knew about his/her existance: \(stranger.id.base64EncodedString().prefix(10))...") + } else { + print(">>> This is a complete stranger. Storing on the db: \($0.base64EncodedString().prefix(10))...") - members.forEach { - if strangers.map(\.id).contains($0.id) { try! database.saveContact(.init( - id: $0.id, + id: $0, marshaled: nil, username: "Fetching...", email: nil, @@ -588,30 +617,27 @@ extension LaunchViewModel { } print(">>> Performing a multi-lookup for group strangers:") - strangers.enumerated().forEach { - print("- Stranger N\($0.offset): \($0.element.id.base64EncodedString().prefix(10))...") - } do { - let multiLookup = try messenger.lookupContacts(ids: strangers.map(\.id)) + let multiLookup = try messenger.lookupContacts(ids: strangers.map { $0 }) for user in multiLookup.contacts { - print("+ Found stranger w/ id: \(try! user.getId().base64EncodedString().prefix(10))...") + print(">>> Found stranger w/ id: \(try! user.getId().base64EncodedString().prefix(10))...") if var foo = try? self.database.fetchContacts(.init(id: [user.getId()])).first, let username = try? user.getFact(.username)?.value { foo.username = username - print("+ Set username: \(username) for \(try! user.getId().base64EncodedString().prefix(10))...") + print(">>> Set username: \(username) for \(try! user.getId().base64EncodedString().prefix(10))...") _ = try? self.database.saveContact(foo) } } for error in multiLookup.errors { - print("+ Failure on Multilookup: \(error.localizedDescription)") + print(">>> Failure on Multilookup: \(error.localizedDescription)") } for failedId in multiLookup.failedIds { - print("+ Failed id: \(failedId.base64EncodedString().prefix(10))...") + print(">>> Failed id: \(failedId.base64EncodedString().prefix(10))...") } } catch { print(">>> Exception on multilookup: \(error.localizedDescription)") diff --git a/Sources/OnboardingFeature/Controllers/OnboardingWelcomeController.swift b/Sources/OnboardingFeature/Controllers/OnboardingWelcomeController.swift index 33455d6627930f945bbadc2ddb19d53a047d5dc8..6def35a43a53695ff916c62761f73f3091966af8 100644 --- a/Sources/OnboardingFeature/Controllers/OnboardingWelcomeController.swift +++ b/Sources/OnboardingFeature/Controllers/OnboardingWelcomeController.swift @@ -1,9 +1,9 @@ -import DrawerFeature import Theme import UIKit import Shared import Combine import Defaults +import DrawerFeature import DependencyInjection public final class OnboardingWelcomeController: UIViewController { diff --git a/Sources/RestoreFeature/Controllers/RestoreSuccessController.swift b/Sources/RestoreFeature/Controllers/RestoreSuccessController.swift index a0624385c1d0143c5826c358f7081ada3573f8b1..fd4f97899558664da35f86da6c1ebfaa8438b0d8 100644 --- a/Sources/RestoreFeature/Controllers/RestoreSuccessController.swift +++ b/Sources/RestoreFeature/Controllers/RestoreSuccessController.swift @@ -1,44 +1,52 @@ import UIKit +import Theme import Combine import DependencyInjection public final class RestoreSuccessController: UIViewController { - @Dependency private var coordinator: RestoreCoordinating - - lazy private var screenView = RestoreSuccessView() - private var cancellables = Set<AnyCancellable>() - - public override func loadView() { - view = screenView - } - - public override func viewDidLoad() { - super.viewDidLoad() - setupBindings() - } - - public override func viewDidLayoutSubviews() { - super.viewDidLayoutSubviews() - - let gradient = CAGradientLayer() - gradient.colors = [ - UIColor(red: 122/255, green: 235/255, blue: 239/255, alpha: 1).cgColor, - UIColor(red: 56/255, green: 204/255, blue: 232/255, alpha: 1).cgColor, - UIColor(red: 63/255, green: 186/255, blue: 253/255, alpha: 1).cgColor, - UIColor(red: 98/255, green: 163/255, blue: 255/255, alpha: 1).cgColor - ] - - gradient.startPoint = CGPoint(x: 0, y: 0) - gradient.endPoint = CGPoint(x: 1, y: 1) - - gradient.frame = screenView.bounds - screenView.layer.insertSublayer(gradient, at: 0) - } - - private func setupBindings() { - screenView.nextButton - .publisher(for: .touchUpInside) - .sink { [unowned self] in coordinator.toChats(from: self) } - .store(in: &cancellables) - } + @Dependency var coordinator: RestoreCoordinating + @Dependency var statusBarController: StatusBarStyleControlling + + lazy private var screenView = RestoreSuccessView() + private var cancellables = Set<AnyCancellable>() + + public override func loadView() { + view = screenView + } + + public override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + statusBarController.style.send(.darkContent) + navigationController?.navigationBar.customize(translucent: true) + } + + public override func viewDidLoad() { + super.viewDidLoad() + setupBindings() + } + + public override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + + let gradient = CAGradientLayer() + gradient.colors = [ + UIColor(red: 122/255, green: 235/255, blue: 239/255, alpha: 1).cgColor, + UIColor(red: 56/255, green: 204/255, blue: 232/255, alpha: 1).cgColor, + UIColor(red: 63/255, green: 186/255, blue: 253/255, alpha: 1).cgColor, + UIColor(red: 98/255, green: 163/255, blue: 255/255, alpha: 1).cgColor + ] + + gradient.startPoint = CGPoint(x: 0, y: 0) + gradient.endPoint = CGPoint(x: 1, y: 1) + + gradient.frame = screenView.bounds + screenView.layer.insertSublayer(gradient, at: 0) + } + + private func setupBindings() { + screenView.nextButton + .publisher(for: .touchUpInside) + .sink { [unowned self] in coordinator.toChats(from: self) } + .store(in: &cancellables) + } } diff --git a/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved b/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved index 04bc2eac29e0142717c1064a139755b2e83cf40d..8e2d54ed77fa92338542461e10b1aeb094c77987 100644 --- a/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -50,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/ekazaev/ChatLayout", "state" : { - "revision" : "5c448c6b14a4c2755b96341b709352654e3d2115", - "version" : "1.2.6" + "revision" : "b7fe23d3ab6c174da6fad66383bfc359c212f465", + "version" : "1.2.7" } }, { @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://git.xx.network/elixxir/client-ios-db.git", "state" : { - "revision" : "f8e3e0088de8301d6c4816e12f0aca1d6f02a280", - "version" : "1.1.0" + "revision" : "16480177beaa6bc80a1c6be25812abd9bcb850ea", + "version" : "1.2.0" } }, { @@ -99,6 +99,15 @@ "version" : "1.3.0" } }, + { + "identity" : "elixxir-dapps-sdk-swift", + "kind" : "remoteSourceControl", + "location" : "https://git.xx.network/elixxir/elixxir-dapps-sdk-swift", + "state" : { + "branch" : "development", + "revision" : "d011281416542b38e302f3ac59b6c658d6438caa" + } + }, { "identity" : "fileprovider", "kind" : "remoteSourceControl", @@ -158,8 +167,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/google/GoogleUtilities.git", "state" : { - "revision" : "22907832079d808e82f1182b21af58ef3880666f", - "version" : "7.8.0" + "revision" : "68ea347bdb1a69e2d2ae2e25cd085b6ef92f64cb", + "version" : "7.9.0" } }, { @@ -167,8 +176,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/groue/GRDB.swift", "state" : { - "revision" : "dd7e7f39e8e4d7a22d258d9809a882f914690b01", - "version" : "5.26.1" + "revision" : "0ac435744a4c67c4ec23a4a671c0d53ce1fee7c6", + "version" : "6.0.0" } }, { @@ -346,8 +355,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf", "state" : { - "revision" : "b8230909dedc640294d7324d37f4c91ad3dcf177", - "version" : "1.20.1" + "revision" : "88c7d15e1242fdb6ecbafbc7926426a19be1e98a", + "version" : "1.20.2" } }, {