From ba698bea5d014f6d87dad118418b89bc2d39dd5c Mon Sep 17 00:00:00 2001 From: Andrew Podkovyrin Date: Wed, 21 Nov 2018 22:06:59 +0300 Subject: [PATCH] =?UTF-8?q?Fix=20'Syncing=20doesn=E2=80=99t=20always=20sho?= =?UTF-8?q?w'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DashWallet/DWRootViewController.m | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/DashWallet/DWRootViewController.m b/DashWallet/DWRootViewController.m index 57c114cc8..2814b09c0 100644 --- a/DashWallet/DWRootViewController.m +++ b/DashWallet/DWRootViewController.m @@ -464,6 +464,10 @@ -(void)setObserversWithDeviceIsJailbroken:(BOOL)jailbroken { [self showErrorBar]; }]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(chainPeerManagerNewBlockNotification) + name:DSChainPeerManagerNewBlockNotification + object:nil]; } - (void)viewWillAppear:(BOOL)animated @@ -950,6 +954,22 @@ - (void)setProgressTo:(NSNumber *)n self.progress.progress = n.floatValue; } +- (void)chainPeerManagerNewBlockNotification +{ + double progress = [DWEnvironment sharedInstance].currentChainPeerManager.syncProgress; + if (progress > DBL_EPSILON && progress + DBL_EPSILON < 1.0) { // not done syncing + if (self.progress.hidden) { + [self startActivityWithTimeout:0]; + } + else { + [self updateProgress]; + } + } + else { + [self stopActivityWithSuccess:YES]; + } +} + - (void)updateProgress { [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(updateProgress) object:nil];