Merge pull request #7140 from vector-im/alfogrillo/badge_threshold

Add threshold for unread messages in all the spaces
This commit is contained in:
Alfonso Grillo 2022-12-13 13:38:56 +01:00 committed by GitHub
commit 7170daa82f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View file

@ -27,7 +27,6 @@ protocol AllChatsViewControllerDelegate: AnyObject {
}
class AllChatsViewController: HomeViewController {
// MARK: - Class methods
static override func nib() -> UINib! {
@ -528,7 +527,16 @@ class AllChatsViewController: HomeViewController {
let notificationCount = session.spaceService.missedNotificationsCount
let hasSpaceInvite = session.spaceService.hasSpaceInvite
let isBadgeHighlighed = session.spaceService.hasHighlightNotification || hasSpaceInvite
let badgeValue = (notificationCount == 0 && hasSpaceInvite) ? "!" : String(notificationCount)
let badgeValue: String
switch notificationCount {
case 0:
badgeValue = hasSpaceInvite ? "!" : "0"
case (1 ... Constants.spacesButtonMaxCount):
badgeValue = "\(notificationCount)"
default:
badgeValue = "\(Constants.spacesButtonMaxCount)+"
}
spacesButton.badgeText = badgeValue
spacesButton.badgeBackgroundColor = isBadgeHighlighed ? theme.noticeColor : theme.noticeSecondaryColor
@ -682,6 +690,12 @@ class AllChatsViewController: HomeViewController {
}
}
private extension AllChatsViewController {
enum Constants {
static let spacesButtonMaxCount: UInt = 999
}
}
// MARK: - SpaceSelectorBottomSheetCoordinatorBridgePresenterDelegate
extension AllChatsViewController: SpaceSelectorBottomSheetCoordinatorBridgePresenterDelegate {
@ -718,7 +732,6 @@ extension AllChatsViewController: SpaceSelectorBottomSheetCoordinatorBridgePrese
// MARK: - UISearchResultsUpdating
extension AllChatsViewController: UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController) {
guard let searchText = searchController.searchBar.text, !searchText.isEmpty else {
self.dataSource.search(withPatterns: nil)
@ -727,7 +740,6 @@ extension AllChatsViewController: UISearchResultsUpdating {
self.dataSource.search(withPatterns: [searchText])
}
}
// MARK: - UISearchControllerDelegate

View file

@ -0,0 +1 @@
Refine badge for messages logic on spaces button.