Minor refactoring

This commit is contained in:
nielsandriesse 2020-07-29 11:58:36 +10:00
parent 3075e82d8a
commit 010a399ee7
2 changed files with 5 additions and 6 deletions

View File

@ -16,9 +16,9 @@ final class NotificationServiceExtension : UNNotificationServiceExtension {
self.contentHandler = contentHandler
notificationContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
// The code using DispatchQueue.main.async { self.setUpIfNecessary(){ Modify the notification content } } will somehow cause a freezing when the second PN comes
// The code using DispatchQueue.main.async { self.setUpIfNecessary() { Modify the notification content } } will somehow cause a freeze when a second PN comes
DispatchQueue.main.sync { self.setUpIfNecessary(){} }
DispatchQueue.main.sync { self.setUpIfNecessary() {} }
AppReadiness.runNowOrWhenAppDidBecomeReady {
if let notificationContent = self.notificationContent {

View File

@ -212,7 +212,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol
isObservingDatabase = isViewVisible && CurrentAppContext().isAppForegroundAndActive()
}
private func updateThreadMapping() {
private func updateYDBThreadMapping() {
uiDatabaseConnection.beginLongLivedReadTransaction()
uiDatabaseConnection.read { transaction in
self.threads.update(with: transaction)
@ -221,7 +221,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol
private func reload() {
AssertIsOnMainThread()
updateThreadMapping()
updateYDBThreadMapping()
threadViewModelCache.removeAll()
tableView.reloadData()
emptyStateView.isHidden = (threadCount != 0)
@ -253,7 +253,6 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol
}
}
}
var sectionChanges = NSArray()
var rowChanges = NSArray()
ext.getSectionChanges(&sectionChanges, rowChanges: &rowChanges, for: notifications, with: threads)
@ -280,7 +279,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol
@objc private func handleApplicationDidBecomeActiveNotification(_ notification: Notification) {
updateIsObservingDatabase()
updateThreadMapping()
updateYDBThreadMapping()
}
@objc private func handleApplicationWillResignActiveNotification(_ notification: Notification) {