Skip to content

Commit

Permalink
Removed the unnessarly Task
Browse files Browse the repository at this point in the history
  • Loading branch information
kcw-grunt committed Apr 23, 2024
1 parent efd3850 commit b01f9c6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 26 deletions.
7 changes: 0 additions & 7 deletions litewallet/BRPeerManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions litewallet/Storyboards/XIBs/SyncProgressHeaderView.xib
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -18,7 +18,7 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="50" id="KGk-i7-Jjw" customClass="SyncProgressHeaderView" customModule="loafwallet" customModuleProvider="target">
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="50" id="KGk-i7-Jjw" customClass="SyncProgressHeaderView" customModule="litewallet" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
Expand All @@ -43,7 +43,7 @@
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="whiteinterditsendIcon" translatesAutoresizingMaskIntoConstraints="NO" id="7zC-fo-fkw">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="white-interdit-send-icon" translatesAutoresizingMaskIntoConstraints="NO" id="7zC-fo-fkw">
<rect key="frame" x="285" y="11" width="25" height="25"/>
<constraints>
<constraint firstAttribute="height" constant="25" id="3Pw-wU-HYc"/>
Expand Down Expand Up @@ -74,6 +74,6 @@
</tableViewCell>
</objects>
<resources>
<image name="whiteinterditsendIcon" width="31" height="31"/>
<image name="white-interdit-send-icon" width="31" height="31"/>
</resources>
</document>
2 changes: 1 addition & 1 deletion litewallet/SyncProgressHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
25 changes: 12 additions & 13 deletions litewallet/TransactionsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TransactionsViewController: UIViewController, UITableViewDelegate, UITable
var selectedIndexes = [IndexPath: NSNumber]()
var shouldBeSyncing: Bool = false
var syncingHeaderView: SyncProgressHeaderView?

var shouldShowPrompt = true

private var transactions: [Transaction] = []
Expand Down Expand Up @@ -78,18 +79,16 @@ class TransactionsViewController: UIViewController, UITableViewDelegate, UITable
/// - reduxState: Current ReduxState
/// - completion: Signals the initialzation of the view
private func initSyncingHeaderView(reduxState: ReduxState, completion: @escaping () -> Void) {
Task(priority: .userInitiated) {
syncingHeaderView = Bundle.main.loadNibNamed("SyncProgressHeaderView",
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?.headerMessage = reduxState.walletState.syncState
syncingHeaderView?.noSendImageView.alpha = 1.0
syncingHeaderView?.timestamp = reduxState.walletState.lastBlockTimestamp

completion()
}
syncingHeaderView = Bundle.main.loadNibNamed("SyncProgressHeaderView",
owner: self,
options: nil)?.first as? SyncProgressHeaderView
syncingHeaderView?.isRescanning = reduxState.walletState.isRescanning
syncingHeaderView?.progress = 0.02
syncingHeaderView?.headerMessage = reduxState.walletState.syncState
syncingHeaderView?.noSendImageView.alpha = 1.0
syncingHeaderView?.timestamp = reduxState.walletState.lastBlockTimestamp

completion()
}

private func attemptShowPrompt() {
Expand Down Expand Up @@ -392,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
Expand Down

0 comments on commit b01f9c6

Please sign in to comment.