mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'dev' into preformance-improvement
This commit is contained in:
commit
1fb4952f5e
|
@ -6,10 +6,8 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
||||||
private var threads: YapDatabaseViewMappings!
|
private var threads: YapDatabaseViewMappings!
|
||||||
private var threadViewModelCache: [String:ThreadViewModel] = [:] // Thread ID to ThreadViewModel
|
private var threadViewModelCache: [String:ThreadViewModel] = [:] // Thread ID to ThreadViewModel
|
||||||
private var tableViewTopConstraint: NSLayoutConstraint!
|
private var tableViewTopConstraint: NSLayoutConstraint!
|
||||||
private var unreadMessageRequestCount: UInt = 0
|
private var unreadMessageRequestCount: UInt {
|
||||||
|
OWSMessageUtils.sharedManager().unreadMessageRequestCount()
|
||||||
private var messageRequestCount: UInt {
|
|
||||||
threads.numberOfItems(inGroup: TSMessageRequestGroup)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var threadCount: UInt {
|
private var threadCount: UInt {
|
||||||
|
@ -189,7 +187,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
||||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
switch section {
|
switch section {
|
||||||
case 0:
|
case 0:
|
||||||
if messageRequestCount > 0 && !CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
if unreadMessageRequestCount > 0 && !CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,9 +272,6 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the number of unread message requests
|
|
||||||
unreadMessageRequestCount = OWSMessageUtils.sharedManager().unreadMessageRequestCount()
|
|
||||||
|
|
||||||
// If there are no unread message requests then hide the message request banner
|
// If there are no unread message requests then hide the message request banner
|
||||||
if unreadMessageRequestCount == 0 {
|
if unreadMessageRequestCount == 0 {
|
||||||
CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] = true
|
CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] = true
|
||||||
|
@ -305,8 +300,6 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
||||||
|
|
||||||
// If we need to unhide the message request row and then re-insert it
|
// If we need to unhide the message request row and then re-insert it
|
||||||
if !messageRequestChanges.isEmpty {
|
if !messageRequestChanges.isEmpty {
|
||||||
// Update the number of unread message requests
|
|
||||||
unreadMessageRequestCount = OWSMessageUtils.sharedManager().unreadMessageRequestCount()
|
|
||||||
|
|
||||||
// If there are no unread message requests then hide the message request banner
|
// If there are no unread message requests then hide the message request banner
|
||||||
if unreadMessageRequestCount == 0 && tableView.numberOfRows(inSection: 0) == 1 {
|
if unreadMessageRequestCount == 0 && tableView.numberOfRows(inSection: 0) == 1 {
|
||||||
|
@ -314,10 +307,10 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
||||||
tableView.deleteRows(at: [IndexPath(row: 0, section: 0)], with: .automatic)
|
tableView.deleteRows(at: [IndexPath(row: 0, section: 0)], with: .automatic)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if tableView.numberOfRows(inSection: 0) == 1 && Int(messageRequestCount) <= 0 {
|
if tableView.numberOfRows(inSection: 0) == 1 && Int(unreadMessageRequestCount) <= 0 {
|
||||||
tableView.deleteRows(at: [IndexPath(row: 0, section: 0)], with: .automatic)
|
tableView.deleteRows(at: [IndexPath(row: 0, section: 0)], with: .automatic)
|
||||||
}
|
}
|
||||||
else if tableView.numberOfRows(inSection: 0) == 0 && Int(messageRequestCount) > 0 && !CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
else if tableView.numberOfRows(inSection: 0) == 0 && Int(unreadMessageRequestCount) > 0 && !CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
||||||
tableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .automatic)
|
tableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .automatic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue