Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/ios.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarinofaggiana <ios@nextcloud.com>2022-08-04 10:25:45 +0300
committermarinofaggiana <ios@nextcloud.com>2022-08-04 10:25:45 +0300
commite48be2833cec1829b94476dd14d89f132d297bd2 (patch)
treedd53a717c27da947e244904c14398fcae92e18d2
parent339c69cc4761091f9e1e78271f55fdad40fec386 (diff)
fix UpdateBadgeNumber
Signed-off-by: marinofaggiana <ios@nextcloud.com>
-rw-r--r--iOSClient/Main/NCMainTabBar.swift18
-rw-r--r--iOSClient/Networking/NCNetworkingProcessUpload.swift1
2 files changed, 12 insertions, 7 deletions
diff --git a/iOSClient/Main/NCMainTabBar.swift b/iOSClient/Main/NCMainTabBar.swift
index 604f3f6b3..ce3d0dd6c 100644
--- a/iOSClient/Main/NCMainTabBar.swift
+++ b/iOSClient/Main/NCMainTabBar.swift
@@ -28,7 +28,6 @@ class NCMainTabBar: UITabBar {
private var fillColor: UIColor!
private var shapeLayer: CALayer?
private let appDelegate = UIApplication.shared.delegate as! AppDelegate
- private var timer: Timer?
public var menuRect: CGRect {
get {
@@ -45,10 +44,17 @@ class NCMainTabBar: UITabBar {
super.init(coder: coder)
appDelegate.mainTabBar = self
- timer = Timer.scheduledTimer(timeInterval: 3, target: self, selector: (#selector(updateBadgeNumber)), userInfo: nil, repeats: true)
NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
+
NotificationCenter.default.addObserver(self, selector: #selector(updateBadgeNumber), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterUpdateBadgeNumber), object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(updateBadgeNumber), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidBecomeActive), object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(updateBadgeNumber), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationWillEnterForeground), object: nil)
+
+ NotificationCenter.default.addObserver(self, selector: #selector(updateBadgeNumber), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterUploadStartFile), object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(updateBadgeNumber), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterUploadedFile), object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(updateBadgeNumber), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterUploadCancelFile), object: nil)
+
barTintColor = NCBrandColor.shared.secondarySystemBackground
backgroundColor = NCBrandColor.shared.secondarySystemBackground
@@ -211,15 +217,13 @@ class NCMainTabBar: UITabBar {
@objc func updateBadgeNumber() {
guard !appDelegate.account.isEmpty else { return }
- let counterDownload = NCOperationQueue.shared.downloadQueueCount()
let counterUpload = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status == %d OR status == %d OR status == %d", NCGlobal.shared.metadataStatusWaitUpload, NCGlobal.shared.metadataStatusInUpload, NCGlobal.shared.metadataStatusUploading)).count
- let total = counterDownload + counterUpload
- UIApplication.shared.applicationIconBadgeNumber = total
+ UIApplication.shared.applicationIconBadgeNumber = counterUpload
if let item = items?[0] {
- if total > 0 {
- item.badgeValue = String(total)
+ if counterUpload > 0 {
+ item.badgeValue = String(counterUpload)
} else {
item.badgeValue = nil
}
diff --git a/iOSClient/Networking/NCNetworkingProcessUpload.swift b/iOSClient/Networking/NCNetworkingProcessUpload.swift
index bf96a477d..07a757b68 100644
--- a/iOSClient/Networking/NCNetworkingProcessUpload.swift
+++ b/iOSClient/Networking/NCNetworkingProcessUpload.swift
@@ -75,6 +75,7 @@ class NCNetworkingProcessUpload: NSObject {
let metadatas = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "sessionSelector == %@ AND status == %d", sessionSelector, NCGlobal.shared.metadataStatusWaitUpload), page: 1, limit: limit, sorted: "date", ascending: true)
if metadatas.count > 0 {
NCCommunicationCommon.shared.writeLog("PROCESS-UPLOAD find \(metadatas.count) items")
+ NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUpdateBadgeNumber)
}
for metadata in metadatas {