mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 21:16:35 +00:00
Fix crash? enum -> struct
This commit is contained in:
parent
dcd0d66c87
commit
fff7ae1a22
@ -178,7 +178,7 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode {
|
||||
|
||||
let unreadCount = values.count(for: .peer(peerView.peerId))
|
||||
if let unreadCount = unreadCount, unreadCount > 0 {
|
||||
unread[peerView.peerId] = isMuted ? .muted(unreadCount) : .unmuted(unreadCount)
|
||||
unread[peerView.peerId] = UnreadSearchBadge(unreadCount: unreadCount, isMuted: isMuted)
|
||||
}
|
||||
|
||||
if let presence = peerView.peerPresences[peer.id] {
|
||||
|
||||
@ -144,16 +144,8 @@ public final class HorizontalPeerItemNode: ListViewItemNode {
|
||||
let badgeAttributedString: NSAttributedString
|
||||
if let unreadBadge = item.unreadBadge {
|
||||
let badgeTextColor: UIColor
|
||||
let unreadCount: Int32
|
||||
let isMuted: Bool
|
||||
switch unreadBadge {
|
||||
case let .muted(_count):
|
||||
unreadCount = _count
|
||||
isMuted = true
|
||||
case let .unmuted(_count):
|
||||
unreadCount = _count
|
||||
isMuted = false
|
||||
}
|
||||
let unreadCount: Int32 = unreadBadge.unreadCount
|
||||
let isMuted: Bool = unreadBadge.isMuted
|
||||
if isMuted {
|
||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundInactive(item.theme)
|
||||
badgeTextColor = item.theme.chatList.unreadBadgeInactiveTextColor
|
||||
|
||||
@ -209,22 +209,8 @@ enum ChatListSearchEntryStableId: Hashable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var hashValue: Int {
|
||||
switch self {
|
||||
case let .localPeerId(peerId):
|
||||
return peerId.hashValue
|
||||
case let .globalPeerId(peerId):
|
||||
return peerId.hashValue
|
||||
case let .messageId(messageId):
|
||||
return messageId.hashValue
|
||||
case .addContact:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum ChatListSearchEntry: Comparable, Identifiable {
|
||||
case localPeer(Peer, Peer?, UnreadSearchBadge?, Int, PresentationTheme, PresentationStrings, PresentationPersonNameOrder, PresentationPersonNameOrder)
|
||||
case globalPeer(FoundPeer, UnreadSearchBadge?, Int, PresentationTheme, PresentationStrings, PresentationPersonNameOrder, PresentationPersonNameOrder)
|
||||
@ -371,7 +357,7 @@ enum ChatListSearchEntry: Comparable, Identifiable {
|
||||
|
||||
var badge: ContactsPeerItemBadge?
|
||||
if let unreadBadge = unreadBadge {
|
||||
badge = ContactsPeerItemBadge(count: unreadBadge.count, type: unreadBadge.isMuted ? .inactive : .active)
|
||||
badge = ContactsPeerItemBadge(count: unreadBadge.unreadCount, type: unreadBadge.isMuted ? .inactive : .active)
|
||||
}
|
||||
|
||||
let header:ChatListSearchItemHeader?
|
||||
@ -415,7 +401,7 @@ enum ChatListSearchEntry: Comparable, Identifiable {
|
||||
|
||||
var badge: ContactsPeerItemBadge?
|
||||
if let unreadBadge = unreadBadge {
|
||||
badge = ContactsPeerItemBadge(count: unreadBadge.count, type: unreadBadge.isMuted ? .inactive : .active)
|
||||
badge = ContactsPeerItemBadge(count: unreadBadge.unreadCount, type: unreadBadge.isMuted ? .inactive : .active)
|
||||
}
|
||||
|
||||
let header:ChatListSearchItemHeader?
|
||||
@ -649,7 +635,7 @@ final class ChatListSearchContainerNode: SearchDisplayControllerContentNode {
|
||||
|
||||
let unreadCount = values.count(for: .peer(peerView.peerId))
|
||||
if let unreadCount = unreadCount, unreadCount > 0 {
|
||||
unread[peerView.peerId] = isMuted ? .muted(unreadCount) : .unmuted(unreadCount)
|
||||
unread[peerView.peerId] = UnreadSearchBadge(unreadCount: unreadCount, isMuted: isMuted)
|
||||
}
|
||||
}
|
||||
return (peers: viewsAndPeers.1, unread: unread)
|
||||
|
||||
@ -1,22 +1,11 @@
|
||||
import Foundation
|
||||
|
||||
public enum UnreadSearchBadge: Equatable {
|
||||
case muted(Int32)
|
||||
case unmuted(Int32)
|
||||
public struct UnreadSearchBadge: Equatable {
|
||||
public var unreadCount: Int32
|
||||
public var isMuted: Bool
|
||||
|
||||
public var count: Int32 {
|
||||
switch self {
|
||||
case let .muted(count), let .unmuted(count):
|
||||
return count
|
||||
}
|
||||
}
|
||||
|
||||
public var isMuted: Bool {
|
||||
switch self {
|
||||
case .muted:
|
||||
return true
|
||||
case .unmuted:
|
||||
return false
|
||||
}
|
||||
public init(unreadCount: Int32, isMuted: Bool) {
|
||||
self.unreadCount = unreadCount
|
||||
self.isMuted = isMuted
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user