From f7c59196748c61390291f022becfd11ccb52956b Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 7 Oct 2017 12:37:11 -0700 Subject: [PATCH] Send DownloadProgressDidChange notification only when numberOfTasks or numberRemaining actually change. --- Frameworks/RSWeb/RSWeb/DownloadProgress.swift | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Frameworks/RSWeb/RSWeb/DownloadProgress.swift b/Frameworks/RSWeb/RSWeb/DownloadProgress.swift index cecb8feff..c3f0d7dc1 100755 --- a/Frameworks/RSWeb/RSWeb/DownloadProgress.swift +++ b/Frameworks/RSWeb/RSWeb/DownloadProgress.swift @@ -10,23 +10,27 @@ import Foundation public extension Notification.Name { - public static let DownloadProgressDidChange = Notification.Name(rawValue: "DownloadProgressDidChangeNotification") + public static let DownloadProgressDidChange = Notification.Name(rawValue: "DownloadProgressDidChange") } -public class DownloadProgress { +public final class DownloadProgress { public var numberOfTasks = 0 { didSet { if numberOfTasks == 0 { numberRemaining = 0 } - postDidChangeNotification() + if numberOfTasks != oldValue { + postDidChangeNotification() + } } } public var numberRemaining = 0 { didSet { - postDidChangeNotification() + if numberRemaining != oldValue { + postDidChangeNotification() + } } } @@ -65,6 +69,8 @@ public class DownloadProgress { } } +// MARK: - Private + private extension DownloadProgress { func postDidChangeNotification() {