From c49b3996322b85c6bead033a4cbb1cad4700e1ca Mon Sep 17 00:00:00 2001 From: Kerry Washington Date: Sat, 11 May 2024 10:05:27 -0700 Subject: [PATCH] Bugfix/general maintenance (#238) * refactor - refactor: function inside WalletCoordinator - fix: invalid data and incorrect subscripting in . - fix: tableview called in the background thread - Auto linter changes - Updated the timer intervals to allow more time for CPU to process - version bump - added privacy nutrition label - Added the new price updating every 3 secs - unused code - unwrapped the Task in SyncHeaderView - Test to emulate DQ Signed-off-by: kcw-grunt * reduced the debounce - Fixed the rescan localization problem - Shortened the sync steps Signed-off-by: kcw-grunt * version bump Signed-off-by: kcw-grunt --------- Signed-off-by: kcw-grunt Co-authored-by: Hassan Ashraf --- litewallet.xcodeproj/project.pbxproj | 12 +++--- litewallet/AppDelegate.swift | 37 ++++++++++++++---- litewallet/ApplicationController.swift | 16 ++++---- .../Contents.json | 0 .../sendTabIconwhiteinterdit.pdf | Bin litewallet/BRAPIClient+Wallet.swift | 15 +++++-- litewallet/BRPeerManager.swift | 7 ---- litewallet/BundleExtension.swift | 12 +++++- litewallet/Constants/Constants+Events.swift | 6 +++ litewallet/Currency.swift | 5 ++- litewallet/Extensions/String+Additions.swift | 33 ++++++++++++++++ litewallet/FeeManager.swift | 10 ++++- litewallet/LockScreenHeaderView.swift | 19 ++++++++- litewallet/LockScreenHeaderViewModel.swift | 14 +++++-- litewallet/ModalPresenter.swift | 12 +++++- litewallet/PartnerData.swift | 13 ------ litewallet/Platform/BRActivityView.swift | 4 -- .../XIBs/SyncProgressHeaderView.xib | 10 ++--- litewallet/SyncProgressHeaderView.swift | 2 +- litewallet/TransactionsViewController.swift | 5 ++- .../ViewControllers/LoginViewController.swift | 26 ++++++------ .../ReScanViewController.swift | 22 ++++------- litewallet/ViewModels/Transaction.swift | 3 ++ litewallet/WalletCoordinator.swift | 5 ++- 24 files changed, 186 insertions(+), 102 deletions(-) rename litewallet/Assets.xcassets/{whiteinterditsendIcon.imageset => white-interdit-send-icon.imageset}/Contents.json (100%) rename litewallet/Assets.xcassets/{whiteinterditsendIcon.imageset => white-interdit-send-icon.imageset}/sendTabIconwhiteinterdit.pdf (100%) diff --git a/litewallet.xcodeproj/project.pbxproj b/litewallet.xcodeproj/project.pbxproj index a384315f7..492d06048 100644 --- a/litewallet.xcodeproj/project.pbxproj +++ b/litewallet.xcodeproj/project.pbxproj @@ -4534,7 +4534,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = litewallet/litewallet.entitlements; - CURRENT_PROJECT_VERSION = 240509.1; + CURRENT_PROJECT_VERSION = 240511.0; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ZV7987N2ZC; EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES; @@ -4550,7 +4550,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.13.3; + MARKETING_VERSION = 3.13.4; ONLY_ACTIVE_ARCH = YES; ON_DEMAND_RESOURCES_INITIAL_INSTALL_TAGS = "initial-resources speakTag"; OTHER_SWIFT_FLAGS = "-DDebug $(inherited)"; @@ -4891,7 +4891,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = litewallet/litewallet.entitlements; - CURRENT_PROJECT_VERSION = 240509.1; + CURRENT_PROJECT_VERSION = 240511.0; DEVELOPMENT_TEAM = ZV7987N2ZC; EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -4906,7 +4906,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.13.3; + MARKETING_VERSION = 3.13.4; ONLY_ACTIVE_ARCH = YES; ON_DEMAND_RESOURCES_INITIAL_INSTALL_TAGS = "initial-resources speakTag"; OTHER_SWIFT_FLAGS = "$(inherited)"; @@ -5032,7 +5032,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = litewallet/litewallet.entitlements; - CURRENT_PROJECT_VERSION = 240509.1; + CURRENT_PROJECT_VERSION = 240511.0; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ZV7987N2ZC; EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = NO; @@ -5048,7 +5048,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.13.3; + MARKETING_VERSION = 3.13.4; ONLY_ACTIVE_ARCH = YES; ON_DEMAND_RESOURCES_INITIAL_INSTALL_TAGS = "initial-resources speakTag"; OTHER_SWIFT_FLAGS = "-DDebug -DTestnet $(inherited)"; diff --git a/litewallet/AppDelegate.swift b/litewallet/AppDelegate.swift index 4d3145629..ada803597 100644 --- a/litewallet/AppDelegate.swift +++ b/litewallet/AppDelegate.swift @@ -14,6 +14,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { requestResourceWith(tag: ["initial-resources", "speakTag"]) { [self] in + + // Language + updateCurrentUserLocale(localeId: Locale.current.identifier) + Bundle.setLanguage(UserDefaults.selectedLanguage) + // Ops let startDate = Partner.partnerKeyPath(name: .litewalletStart) if startDate == "error-litewallet-start-key" { @@ -24,14 +29,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate { self.setFirebaseConfiguration() // Pusher - self.pushNotifications.start(instanceId: Partner.partnerKeyPath(name: .pusherStaging)) - let generaliOSInterest = "general-ios" - let debugGeneraliOSInterest = "debug-general-ios" + self.pushNotifications.start(instanceId: Partner.partnerKeyPath(name: .pusher)) + let generalInterest = String.preferredLanguageInterest(currentId: UserDefaults.selectedLanguage) + let debugGeneralInterest = "debug-general" + + try? self.pushNotifications.clearDeviceInterests() try? self.pushNotifications - .addDeviceInterest(interest: generaliOSInterest) + .addDeviceInterest(interest: generalInterest) try? self.pushNotifications - .addDeviceInterest(interest: debugGeneraliOSInterest) + .addDeviceInterest(interest: debugGeneralInterest) let interests = self.pushNotifications.getDeviceInterests()?.joined(separator: "|") ?? "" let device = UIDevice.current.identifierForVendor?.uuidString ?? "ID" @@ -40,6 +47,23 @@ class AppDelegate: UIResponder, UIApplicationDelegate { LWAnalytics.logEventWithParameters(itemName: ._20231202_RIGI, properties: interestsDict) + + let current = UNUserNotificationCenter.current() + + current.getNotificationSettings(completionHandler: { settings in + + debugPrint(settings.debugDescription) + if settings.authorizationStatus == .denied { + self.pushNotifications.clearAllState { + LWAnalytics.logEventWithParameters(itemName: ._20240506_DPN) + } + + self.pushNotifications.stop { + LWAnalytics.logEventWithParameters(itemName: ._20240510_SPN) + } + } + }) + } onFailure: { error in let properties: [String: String] = ["error_type": "on_demand_resources_not_found", @@ -47,7 +71,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: properties) } - updateCurrentUserLocale(localeId: Locale.current.identifier) guard let thisWindow = window else { return false } @@ -59,8 +82,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { LWAnalytics.logEventWithParameters(itemName: ._20191105_AL) - Bundle.setLanguage(UserDefaults.selectedLanguage) - return true } diff --git a/litewallet/ApplicationController.swift b/litewallet/ApplicationController.swift index 635cef695..7e03eb85c 100644 --- a/litewallet/ApplicationController.swift +++ b/litewallet/ApplicationController.swift @@ -113,7 +113,7 @@ class ApplicationController: Subscriber, Trackable { } exchangeUpdater?.refresh(completion: {}) feeUpdater?.refresh() - walletManager.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } + // walletManager.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } if modalPresenter?.walletManager == nil { modalPresenter?.walletManager = walletManager } @@ -127,7 +127,7 @@ class ApplicationController: Subscriber, Trackable { } exchangeUpdater?.refresh(completion: {}) feeUpdater?.refresh() - walletManager.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } + // walletManager.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } if modalPresenter?.walletManager == nil { modalPresenter?.walletManager = walletManager } @@ -143,7 +143,7 @@ class ApplicationController: Subscriber, Trackable { if !store.state.isLoginRequired { UserDefaults.standard.set(Date().timeIntervalSince1970, forKey: timeSinceLastExitKey) } - walletManager?.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } + // walletManager?.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } } func performFetch(_ completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { @@ -169,7 +169,9 @@ class ApplicationController: Subscriber, Trackable { walletCoordinator = WalletCoordinator(walletManager: walletManager, store: store) modalPresenter = ModalPresenter(store: store, walletManager: walletManager, window: window, apiClient: noAuthApiClient) exchangeUpdater = ExchangeUpdater(store: store, walletManager: walletManager) - feeUpdater = FeeUpdater(walletManager: walletManager, store: store) + + guard let exchangeUpdaterWithFee = exchangeUpdater else { return } + feeUpdater = FeeUpdater(walletManager: walletManager, store: store, exchangeUpdater: exchangeUpdaterWithFee) startFlowController = StartFlowPresenter(store: store, walletManager: walletManager, rootViewController: rootViewController) mainViewController?.walletManager = walletManager defaultsUpdater = UserDefaultsUpdater(walletManager: walletManager) @@ -225,9 +227,7 @@ class ApplicationController: Subscriber, Trackable { defaultsUpdater?.refresh() walletManager?.apiClient?.events?.up() - exchangeUpdater?.refresh(completion: { - NSLog("::: Refreshed fiat rates") - }) + exchangeUpdater?.refresh(completion: {}) } private func addWalletCreationListener() { @@ -265,7 +265,7 @@ class ApplicationController: Subscriber, Trackable { } private func offMainInitialization() { - DispatchQueue.global(qos: .background).async { + Task(priority: .background) { _ = Rate.symbolMap // Initialize currency symbol map } } diff --git a/litewallet/Assets.xcassets/whiteinterditsendIcon.imageset/Contents.json b/litewallet/Assets.xcassets/white-interdit-send-icon.imageset/Contents.json similarity index 100% rename from litewallet/Assets.xcassets/whiteinterditsendIcon.imageset/Contents.json rename to litewallet/Assets.xcassets/white-interdit-send-icon.imageset/Contents.json diff --git a/litewallet/Assets.xcassets/whiteinterditsendIcon.imageset/sendTabIconwhiteinterdit.pdf b/litewallet/Assets.xcassets/white-interdit-send-icon.imageset/sendTabIconwhiteinterdit.pdf similarity index 100% rename from litewallet/Assets.xcassets/whiteinterditsendIcon.imageset/sendTabIconwhiteinterdit.pdf rename to litewallet/Assets.xcassets/white-interdit-send-icon.imageset/sendTabIconwhiteinterdit.pdf diff --git a/litewallet/BRAPIClient+Wallet.swift b/litewallet/BRAPIClient+Wallet.swift index 4d42a09db..09a94c834 100644 --- a/litewallet/BRAPIClient+Wallet.swift +++ b/litewallet/BRAPIClient+Wallet.swift @@ -1,12 +1,11 @@ import Foundation -private let fallbackRatesURL = "https://api.loshan.co.uk/api/v1/rates" +private let fallbackRatesURL = "https://api-dev.lite-wallet.org/v1/rates" extension BRAPIClient { func feePerKb(_ handler: @escaping (_ fees: Fees, _ error: String?) -> Void) { let req = URLRequest(url: url("/fee-per-kb")) let task = dataTaskWithRequest(req) { _, _, _ in - // TODO: Refactor when mobile-api v0.4.0 is in prod let staticFees = Fees.usingDefaultValues handler(staticFees, nil) } @@ -15,27 +14,35 @@ extension BRAPIClient { func exchangeRates(isFallback: Bool = false, _ handler: @escaping (_ rates: [Rate], _ error: String?) -> Void) { let request = isFallback ? URLRequest(url: URL(string: fallbackRatesURL)!) : URLRequest(url: URL(string: APIServer.baseUrl + "v1/rates")!) - _ = dataTaskWithRequest(request) { data, _, error in + dataTaskWithRequest(request) { data, _, error in if error == nil, let data = data, let parsedData = try? JSONSerialization.jsonObject(with: data, options: .allowFragments) { if isFallback { guard let array = parsedData as? [Any] else { - return handler([], "/rates didn't return an array") + let properties = ["error_message": "is_fallback_no_rate_array_returned"] + LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: properties) + return handler([], "::: /rates didn't return an array") } handler(array.compactMap { Rate(data: $0) }, nil) } else { guard let array = parsedData as? [Any] else { + let properties = ["error_message": "is_fallback_parsed_data_fail"] + LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: properties) return handler([], "/rates didn't return an array") } handler(array.compactMap { Rate(data: $0) }, nil) } } else { if isFallback { + let properties: [String: String] = ["error_message": "is_fallback_no_rate_array_returned"] + LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: properties) handler([], "Error fetching from fallback url") } else { + let properties: [String: String] = ["error_message": "is_fallback"] + LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: properties) self.exchangeRates(isFallback: true, handler) } } diff --git a/litewallet/BRPeerManager.swift b/litewallet/BRPeerManager.swift index b7bfbc8f6..44e0e4900 100644 --- a/litewallet/BRPeerManager.swift +++ b/litewallet/BRPeerManager.swift @@ -90,13 +90,6 @@ class BRPeerManager { return BRPeerManagerEstimatedBlockHeight(cPtr) } - // Only show syncing view if more than 2 days behind - var shouldShowSyncingView: Bool { - let lastBlock = Date(timeIntervalSince1970: TimeInterval(lastBlockTimestamp)) - let cutoff = Date().addingTimeInterval(-24 * 60 * 60 * 2) // 2 days ago - return lastBlock.compare(cutoff) == .orderedAscending - } - // current network sync progress from 0 to 1 // startHeight is the block height of the most recent fully completed sync func syncProgress(fromStartHeight: UInt32) -> Double { diff --git a/litewallet/BundleExtension.swift b/litewallet/BundleExtension.swift index b45b085a3..7494709f5 100644 --- a/litewallet/BundleExtension.swift +++ b/litewallet/BundleExtension.swift @@ -22,8 +22,16 @@ public extension Bundle { object_setClass(Bundle.main, BundleEx.self as AnyClass) } - if let temp = language { - guard let bundle = Bundle(path: Bundle.main.path(forResource: temp, ofType: "lproj")!) else { + if var temp = language { + if temp == "zh" { + temp = "zh-Hans" + } + + guard let path = Bundle.main.path(forResource: temp, ofType: "lproj") else { + LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR) + return + } + guard let bundle = Bundle(path: path) else { LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR) return } diff --git a/litewallet/Constants/Constants+Events.swift b/litewallet/Constants/Constants+Events.swift index b2c8bc891..a0fc630e9 100644 --- a/litewallet/Constants/Constants+Events.swift +++ b/litewallet/Constants/Constants+Events.swift @@ -231,4 +231,10 @@ enum CustomEvent: String { /// Transactions info case _20240315_AI = "application_info" + + /// Disabled Push Notifications + case _20240506_DPN = "disabled_push_notifications" + + /// Stop Push Notifications + case _20240510_SPN = "stopped_push_notifications" } diff --git a/litewallet/Currency.swift b/litewallet/Currency.swift index 74f771e3e..fccc34fff 100644 --- a/litewallet/Currency.swift +++ b/litewallet/Currency.swift @@ -3,7 +3,10 @@ import UIKit class Currency { class func getSymbolForCurrencyCode(code: String) -> String? { - let result = Locale.availableIdentifiers.map { Locale(identifier: $0) }.first { $0.currencyCode == code } + print(" ::: \(code)") + let result = Locale.availableIdentifiers.map { + Locale(identifier: $0) + }.first { $0.currencyCode == code } return result?.currencySymbol } } diff --git a/litewallet/Extensions/String+Additions.swift b/litewallet/Extensions/String+Additions.swift index 3808b4e38..c7e83d9a1 100644 --- a/litewallet/Extensions/String+Additions.swift +++ b/litewallet/Extensions/String+Additions.swift @@ -103,6 +103,39 @@ extension String { } } +// MARK: - Language code String + +extension String { + /// 14 Languages + /// Locale.current.identifier) + static func preferredLanguageInterest(currentId: String) -> String { + var codeId = "" + if (currentId == "zh_CN") || (currentId == "zh_SG") { + return "general-chinese-simplified" + } else if (currentId == "zh_TW") || (currentId == "zh_HK") { + return "general-chinese-traditional" + } else { + codeId = String(currentId.suffix(2)) + } + + switch codeId { + case "en": return "general-english" + case "fr": return "general-french" + case "de": return "general-german" + case "id": return "general-indonesian" + case "it": return "general-italian" + case "ja": return "general-japanese" + case "ko": return "general-korean" + case "pt": return "general-portuguese" + case "ru": return "general-russian" + case "es": return "general-spanish" + case "tr": return "general-turkish" + case "uk": return "general-ukrainian" + default: return "general-english" + } + } +} + extension UnicodeScalar { var nibble: UInt8? { if value >= 48, value <= 57 { diff --git a/litewallet/FeeManager.swift b/litewallet/FeeManager.swift index 1ddb579a2..8967a7250 100644 --- a/litewallet/FeeManager.swift +++ b/litewallet/FeeManager.swift @@ -36,13 +36,15 @@ class FeeUpdater: Trackable { private let maxFeePerKB = Fees.usingDefaultValues.luxury private var timer: Timer? - private let feeUpdateInterval: TimeInterval = 15 // meet Nyquist for api server interval (30) + private let feeUpdateInterval: TimeInterval = 3 + private var exchangeUpdater: ExchangeUpdater // MARK: - Public - init(walletManager: WalletManager, store: Store) { + init(walletManager: WalletManager, store: Store, exchangeUpdater: ExchangeUpdater) { self.walletManager = walletManager self.store = store + self.exchangeUpdater = exchangeUpdater } func refresh(completion: @escaping () -> Void) { @@ -79,5 +81,9 @@ class FeeUpdater: Trackable { @objc func intervalRefresh() { refresh(completion: {}) + exchangeUpdater.refresh(completion: { + /// DEV: For testing + /// NSLog("::: Rate updated") + }) } } diff --git a/litewallet/LockScreenHeaderView.swift b/litewallet/LockScreenHeaderView.swift index d40781860..b26823910 100644 --- a/litewallet/LockScreenHeaderView.swift +++ b/litewallet/LockScreenHeaderView.swift @@ -6,6 +6,12 @@ struct LockScreenHeaderView: View { @ObservedObject var viewModel: LockScreenViewModel + @State + private var fiatValue = "" + + @State + private var currentFiatValue = S.History.currentLitecoinValue.localize() + init(viewModel: LockScreenViewModel) { self.viewModel = viewModel } @@ -17,15 +23,24 @@ struct LockScreenHeaderView: View { .overlay( VStack { Spacer() - Text(" 1 LTC = \(viewModel.currentValueInFiat)") + Text(fiatValue) .font(Font(UIFont.barlowSemiBold(size: 16.0))) .foregroundColor(.white) - Text("\(S.History.currentLitecoinValue.localize()) \(viewModel.currencyCode)") + Text(currentFiatValue) .font(Font(UIFont.barlowRegular(size: 14.0))) .foregroundColor(.white) .padding(.bottom, 10) Divider().background(.white) }) + .onAppear { + Task { + fiatValue = " 1 LTC = \(viewModel.currentValueInFiat)" + currentFiatValue = "\(S.History.currentLitecoinValue.localize()) \(viewModel.currencyCode)" + } + } + .onChange(of: viewModel.currentValueInFiat) { newValue in + fiatValue = " 1 LTC = \(newValue)" + } } } diff --git a/litewallet/LockScreenHeaderViewModel.swift b/litewallet/LockScreenHeaderViewModel.swift index 9b73e574a..379603b88 100644 --- a/litewallet/LockScreenHeaderViewModel.swift +++ b/litewallet/LockScreenHeaderViewModel.swift @@ -31,11 +31,17 @@ class LockScreenViewModel: ObservableObject, Subscriber { } // Price Label - let fiatRate = Double(round(100 * currentRate.rate / 100)) - let formattedFiatString = String(format: "%.02f", fiatRate) + let formattedRate = String(format: "%.02f", currentRate.rate) currencyCode = currentRate.code - let currencySymbol = Currency.getSymbolForCurrencyCode(code: currencyCode) ?? "" - currentValueInFiat = String(currencySymbol + formattedFiatString) + + if let symbol = Rate.symbolMap[currencyCode] { + currentValueInFiat = String(symbol + formattedRate) + } else { + let properties = ["error_message": "fiat_symbol_not_found", + "missing_code": "\(currencyCode)"] + LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: properties) + currentValueInFiat = String("" + formattedRate) + } } // MARK: - Add Subscriptions diff --git a/litewallet/ModalPresenter.swift b/litewallet/ModalPresenter.swift index 35fd280dc..f23fe2aed 100644 --- a/litewallet/ModalPresenter.swift +++ b/litewallet/ModalPresenter.swift @@ -494,7 +494,17 @@ class ModalPresenter: Subscriber, Trackable { settingsNav.pushViewController(localeView, animated: true) }), Setting(title: S.Settings.sync.localize(), callback: { - settingsNav.pushViewController(ReScanViewController(store: self.store), animated: true) + let alert = UIAlertController(title: S.ReScan.alertTitle.localize(), message: S.ReScan.alertMessage.localize(), preferredStyle: .alert) + alert.addAction(UIAlertAction(title: S.Button.cancel.localize(), style: .default, handler: { _ in + alert.dismiss(animated: true) + })) + alert.addAction(UIAlertAction(title: S.ReScan.alertAction.localize(), style: .default, handler: { _ in + self.store.trigger(name: .rescan) + LWAnalytics.logEventWithParameters(itemName: ._20200112_DSR) + alert.dismiss(animated: true) + self.topViewController?.dismiss(animated: true) + })) + self.topViewController?.present(alert, animated: true) }), Setting(title: S.UpdatePin.updateTitle.localize(), callback: strongify(self) { myself in let updatePin = UpdatePinViewController(store: myself.store, walletManager: walletManager, type: .update) diff --git a/litewallet/PartnerData.swift b/litewallet/PartnerData.swift index c8f20bd67..663b85ed4 100644 --- a/litewallet/PartnerData.swift +++ b/litewallet/PartnerData.swift @@ -6,7 +6,6 @@ enum PartnerName { case litewalletOps case litewalletStart case pusher - case pusherStaging } struct Partner { @@ -91,18 +90,6 @@ struct Partner { LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription]) return errorDescription } - - case .pusherStaging: - - if let dictionary = NSDictionary(contentsOfFile: filePath) as? [String: AnyObject], - let key = dictionary["pusher-staging-instance-id"] as? String - { - return key - } else { - let errorDescription = "error_pusher_id_key" - LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription]) - return errorDescription - } } } diff --git a/litewallet/Platform/BRActivityView.swift b/litewallet/Platform/BRActivityView.swift index c9daaacdc..883490dbf 100644 --- a/litewallet/Platform/BRActivityView.swift +++ b/litewallet/Platform/BRActivityView.swift @@ -7,10 +7,6 @@ class BRActivityViewController: UIViewController { super.init(nibName: nil, bundle: nil) modalTransitionStyle = .crossDissolve - if #available(iOS 8.0, *) { - modalPresentationStyle = .overFullScreen - } - activityView.messageLabel.text = message view = activityView } diff --git a/litewallet/Storyboards/XIBs/SyncProgressHeaderView.xib b/litewallet/Storyboards/XIBs/SyncProgressHeaderView.xib index 86811b641..68dd55123 100644 --- a/litewallet/Storyboards/XIBs/SyncProgressHeaderView.xib +++ b/litewallet/Storyboards/XIBs/SyncProgressHeaderView.xib @@ -1,9 +1,9 @@ - + - + @@ -18,7 +18,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -74,6 +74,6 @@ - + diff --git a/litewallet/SyncProgressHeaderView.swift b/litewallet/SyncProgressHeaderView.swift index 244e7ef0f..2d0767ab5 100644 --- a/litewallet/SyncProgressHeaderView.swift +++ b/litewallet/SyncProgressHeaderView.swift @@ -39,7 +39,7 @@ class SyncProgressHeaderView: UITableViewCell, Subscriber { headerLabel.text = S.SyncingHeader.rescanning.localize() timestampLabel.text = "" progressView.alpha = 0.0 - noSendImageView.alpha = 0.0 + noSendImageView.alpha = 1.0 } else { headerLabel.text = "" timestampLabel.text = "" diff --git a/litewallet/TransactionsViewController.swift b/litewallet/TransactionsViewController.swift index a368a4a04..dd5a141c3 100644 --- a/litewallet/TransactionsViewController.swift +++ b/litewallet/TransactionsViewController.swift @@ -18,6 +18,7 @@ class TransactionsViewController: UIViewController, UITableViewDelegate, UITable var selectedIndexes = [IndexPath: NSNumber]() var shouldBeSyncing: Bool = false var syncingHeaderView: SyncProgressHeaderView? + var shouldShowPrompt = true private var transactions: [Transaction] = [] @@ -84,7 +85,7 @@ class TransactionsViewController: UIViewController, UITableViewDelegate, UITable owner: self, options: nil)?.first as? SyncProgressHeaderView syncingHeaderView?.isRescanning = reduxState.walletState.isRescanning - syncingHeaderView?.progress = 0.02 // Small value to show user it is in process + syncingHeaderView?.progress = 0.02 syncingHeaderView?.headerMessage = reduxState.walletState.syncState syncingHeaderView?.noSendImageView.alpha = 1.0 syncingHeaderView?.timestamp = reduxState.walletState.lastBlockTimestamp @@ -390,7 +391,7 @@ class TransactionsViewController: UIViewController, UITableViewDelegate, UITable self.shouldBeSyncing = true self.initSyncingHeaderView(reduxState: reduxState, completion: { self.syncingHeaderView?.isRescanning = reduxState.walletState.isRescanning - self.syncingHeaderView?.progress = 0.02 // Small value to show user it is in process + self.syncingHeaderView?.progress = 0.02 self.syncingHeaderView?.headerMessage = reduxState.walletState.syncState self.syncingHeaderView?.noSendImageView.alpha = 1.0 self.syncingHeaderView?.timestamp = reduxState.walletState.lastBlockTimestamp diff --git a/litewallet/ViewControllers/LoginViewController.swift b/litewallet/ViewControllers/LoginViewController.swift index 96f3785a5..4e6fca6c1 100644 --- a/litewallet/ViewControllers/LoginViewController.swift +++ b/litewallet/ViewControllers/LoginViewController.swift @@ -31,9 +31,8 @@ class LoginViewController: UIViewController, Subscriber, Trackable { pinView = PinView(style: .login, length: store.state.pinLength) } - let viewModel = LockScreenViewModel(store: self.store) + let viewModel = LockScreenViewModel(store: store) headerView = UIHostingController(rootView: LockScreenHeaderView(viewModel: viewModel)) - super.init(nibName: nil, bundle: nil) } @@ -51,7 +50,7 @@ class LoginViewController: UIViewController, Subscriber, Trackable { return view }() - private let headerView: UIHostingController + private var headerView: UIHostingController private let pinPadViewController = PinPadViewController(style: .clear, keyboardType: .pinPad, maxDigits: 0) private let pinViewContainer = UIView() private var pinView: PinView? @@ -59,6 +58,15 @@ class LoginViewController: UIViewController, Subscriber, Trackable { private let disabledView: WalletDisabledView private let activityView = UIActivityIndicatorView(style: .large) private let wipeBannerButton = UIButton() + private let enterPINLabel = UILabel(font: .barlowSemiBold(size: 18), color: .white) + private var pinPadBottom: NSLayoutConstraint? + private var topControlTop: NSLayoutConstraint? + private var unlockTimer: Timer? + private var pinPadBackground = UIView() + private var hasAttemptedToShowBiometrics = false + private var isResetting = false + private let versionLabel = UILabel(font: .barlowRegular(size: 12), color: .white) + private var isWalletEmpty = false var delegate: LoginViewControllerDelegate? @@ -89,17 +97,6 @@ class LoginViewController: UIViewController, Subscriber, Trackable { return button }() - private let enterPINLabel = UILabel(font: .barlowSemiBold(size: 18), color: .white) - private var pinPadBottom: NSLayoutConstraint? - private var topControlTop: NSLayoutConstraint? - private var unlockTimer: Timer? - private var pinPadBackground = UIView() - private var hasAttemptedToShowBiometrics = false - private let lockedOverlay = UIVisualEffectView() - private var isResetting = false - private let versionLabel = UILabel(font: .barlowRegular(size: 12), color: .white) - private var isWalletEmpty = false - override func viewDidLoad() { checkWalletBalance() addSubviews() @@ -431,7 +428,6 @@ class LoginViewController: UIViewController, Subscriber, Trackable { if let disabledUntil = walletManager?.walletDisabledUntil { let now = Date().timeIntervalSince1970 if disabledUntil > now { - saveEvent("login.locked") let disabledUntilDate = Date(timeIntervalSince1970: disabledUntil) let unlockInterval = disabledUntil - now let df = DateFormatter() diff --git a/litewallet/ViewControllers/ReScanViewController.swift b/litewallet/ViewControllers/ReScanViewController.swift index caef3efd1..2f9a8bf20 100644 --- a/litewallet/ViewControllers/ReScanViewController.swift +++ b/litewallet/ViewControllers/ReScanViewController.swift @@ -3,7 +3,6 @@ import UIKit class ReScanViewController: UIViewController, Subscriber { init(store: Store) { self.store = store - faq = .buildFaqButton(store: store, articleId: ArticleIds.nothing) super.init(nibName: nil, bundle: nil) } @@ -12,7 +11,6 @@ class ReScanViewController: UIViewController, Subscriber { private let button = ShadowButton(title: S.ReScan.buttonTitle.localize(), type: .primary) private let footer = UILabel.wrapping(font: .customBody(size: 16.0), color: .secondaryGrayText) private let store: Store - private let faq: UIButton deinit { store.unsubscribe(self) @@ -26,7 +24,6 @@ class ReScanViewController: UIViewController, Subscriber { private func addSubviews() { view.addSubview(header) - view.addSubview(faq) view.addSubview(body) view.addSubview(button) view.addSubview(footer) @@ -36,21 +33,16 @@ class ReScanViewController: UIViewController, Subscriber { header.constrain([ header.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: C.padding[2]), header.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: C.padding[2]), - ]) - faq.constrain([ - faq.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -C.padding[2]), - faq.centerYAnchor.constraint(equalTo: header.centerYAnchor), - faq.widthAnchor.constraint(equalToConstant: 44.0), - faq.heightAnchor.constraint(equalToConstant: 44.0), + header.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: C.padding[-2]), ]) body.constrain([ body.leadingAnchor.constraint(equalTo: header.leadingAnchor), body.topAnchor.constraint(equalTo: header.bottomAnchor, constant: C.padding[2]), - body.trailingAnchor.constraint(equalTo: faq.trailingAnchor), + body.trailingAnchor.constraint(equalTo: header.trailingAnchor), ]) footer.constrain([ footer.leadingAnchor.constraint(equalTo: header.leadingAnchor), - footer.trailingAnchor.constraint(equalTo: faq.trailingAnchor), + footer.trailingAnchor.constraint(equalTo: header.trailingAnchor), footer.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -C.padding[3]), ]) button.constrain([ @@ -90,10 +82,10 @@ class ReScanViewController: UIViewController, Subscriber { let bodyAttributes = [NSAttributedString.Key.font: UIFont.customBody(size: 16.0), NSAttributedString.Key.foregroundColor: UIColor.darkText] - body.append(NSAttributedString(string: "\(S.ReScan.subheader1)\n", attributes: headerAttributes)) - body.append(NSAttributedString(string: "\(S.ReScan.body1)\n\n", attributes: bodyAttributes)) - body.append(NSAttributedString(string: "\(S.ReScan.subheader2)\n", attributes: headerAttributes)) - body.append(NSAttributedString(string: "\(S.ReScan.body2)\n\n\(S.ReScan.body3)", attributes: bodyAttributes)) + body.append(NSAttributedString(string: "\(S.ReScan.subheader1.localize())\n", attributes: headerAttributes)) + body.append(NSAttributedString(string: "\(S.ReScan.body1.localize())\n\n", attributes: bodyAttributes)) + body.append(NSAttributedString(string: "\(S.ReScan.subheader2.localize())\n", attributes: headerAttributes)) + body.append(NSAttributedString(string: "\(S.ReScan.body2.localize())\n\n\(S.ReScan.body3.localize())", attributes: bodyAttributes)) return body } diff --git a/litewallet/ViewModels/Transaction.swift b/litewallet/ViewModels/Transaction.swift index ac20d50cd..8dc0b8405 100644 --- a/litewallet/ViewModels/Transaction.swift +++ b/litewallet/ViewModels/Transaction.swift @@ -219,6 +219,9 @@ class Transaction { } var comment: String? { + if metaData?.comment != nil { + print("=== memo comments \(metaData?.comment ?? "NO MEMO")") + } return metaData?.comment } diff --git a/litewallet/WalletCoordinator.swift b/litewallet/WalletCoordinator.swift index d2859b94f..784c24f27 100644 --- a/litewallet/WalletCoordinator.swift +++ b/litewallet/WalletCoordinator.swift @@ -4,7 +4,7 @@ import UIKit private let lastBlockHeightKey = "LastBlockHeightKey" private let progressUpdateInterval: TimeInterval = 1.0 -private let updateDebounceInterval: TimeInterval = 3.0 +private let updateDebounceInterval: TimeInterval = 1.0 class WalletCoordinator: Subscriber, Trackable { var kvStore: BRReplicatedKVStore? { @@ -158,7 +158,8 @@ class WalletCoordinator: Subscriber, Trackable { return transactions.compactMap { $0 }.sorted { $0.pointee.timestamp > $1.pointee.timestamp - }.compactMap { + } + .compactMap { Transaction($0, walletManager: walletManager, kvStore: kvStore, rate: rate) } }