Change refresh indicator to never use seconds. Issue #1524
This commit is contained in:
parent
9550b29a01
commit
bd7449cc84
|
@ -14,7 +14,6 @@ class RefreshProgressView: UIView {
|
||||||
@IBOutlet weak var progressView: UIProgressView!
|
@IBOutlet weak var progressView: UIProgressView!
|
||||||
@IBOutlet weak var label: UILabel!
|
@IBOutlet weak var label: UILabel!
|
||||||
private lazy var progressWidth = progressView.widthAnchor.constraint(equalToConstant: 100.0)
|
private lazy var progressWidth = progressView.widthAnchor.constraint(equalToConstant: 100.0)
|
||||||
private var lastLabelDisplayedTime: Date? = nil
|
|
||||||
|
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(progressDidChange(_:)), name: .AccountRefreshProgressDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(progressDidChange(_:)), name: .AccountRefreshProgressDidChange, object: nil)
|
||||||
|
@ -29,13 +28,7 @@ class RefreshProgressView: UIView {
|
||||||
func updateRefreshLabel() {
|
func updateRefreshLabel() {
|
||||||
if let accountLastArticleFetchEndTime = AccountManager.shared.lastArticleFetchEndTime {
|
if let accountLastArticleFetchEndTime = AccountManager.shared.lastArticleFetchEndTime {
|
||||||
|
|
||||||
if let lastLabelDisplayedTime = lastLabelDisplayedTime, lastLabelDisplayedTime.addingTimeInterval(2) > Date() {
|
if Date() > accountLastArticleFetchEndTime.addingTimeInterval(60) {
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
lastLabelDisplayedTime = Date()
|
|
||||||
|
|
||||||
if Date() > accountLastArticleFetchEndTime.addingTimeInterval(1) {
|
|
||||||
|
|
||||||
let relativeDateTimeFormatter = RelativeDateTimeFormatter()
|
let relativeDateTimeFormatter = RelativeDateTimeFormatter()
|
||||||
relativeDateTimeFormatter.dateTimeStyle = .named
|
relativeDateTimeFormatter.dateTimeStyle = .named
|
||||||
|
@ -45,7 +38,7 @@ class RefreshProgressView: UIView {
|
||||||
label.text = refreshText
|
label.text = refreshText
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
label.text = NSLocalizedString("Updated just now", comment: "Updated Just Now")
|
label.text = NSLocalizedString("Updated Just Now", comment: "Updated Just Now")
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -80,7 +73,6 @@ private extension RefreshProgressView {
|
||||||
self.progressWidth.isActive = false
|
self.progressWidth.isActive = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lastLabelDisplayedTime = nil
|
|
||||||
label.isHidden = true
|
label.isHidden = true
|
||||||
progressView.isHidden = false
|
progressView.isHidden = false
|
||||||
self.progressWidth.isActive = true
|
self.progressWidth.isActive = true
|
||||||
|
|
Loading…
Reference in New Issue