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))
|
let unreadCount = values.count(for: .peer(peerView.peerId))
|
||||||
if let unreadCount = unreadCount, unreadCount > 0 {
|
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] {
|
if let presence = peerView.peerPresences[peer.id] {
|
||||||
|
|||||||
@ -144,16 +144,8 @@ public final class HorizontalPeerItemNode: ListViewItemNode {
|
|||||||
let badgeAttributedString: NSAttributedString
|
let badgeAttributedString: NSAttributedString
|
||||||
if let unreadBadge = item.unreadBadge {
|
if let unreadBadge = item.unreadBadge {
|
||||||
let badgeTextColor: UIColor
|
let badgeTextColor: UIColor
|
||||||
let unreadCount: Int32
|
let unreadCount: Int32 = unreadBadge.unreadCount
|
||||||
let isMuted: Bool
|
let isMuted: Bool = unreadBadge.isMuted
|
||||||
switch unreadBadge {
|
|
||||||
case let .muted(_count):
|
|
||||||
unreadCount = _count
|
|
||||||
isMuted = true
|
|
||||||
case let .unmuted(_count):
|
|
||||||
unreadCount = _count
|
|
||||||
isMuted = false
|
|
||||||
}
|
|
||||||
if isMuted {
|
if isMuted {
|
||||||
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundInactive(item.theme)
|
currentBadgeBackgroundImage = PresentationResourcesChatList.badgeBackgroundInactive(item.theme)
|
||||||
badgeTextColor = item.theme.chatList.unreadBadgeInactiveTextColor
|
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 {
|
enum ChatListSearchEntry: Comparable, Identifiable {
|
||||||
case localPeer(Peer, Peer?, UnreadSearchBadge?, Int, PresentationTheme, PresentationStrings, PresentationPersonNameOrder, PresentationPersonNameOrder)
|
case localPeer(Peer, Peer?, UnreadSearchBadge?, Int, PresentationTheme, PresentationStrings, PresentationPersonNameOrder, PresentationPersonNameOrder)
|
||||||
case globalPeer(FoundPeer, 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?
|
var badge: ContactsPeerItemBadge?
|
||||||
if let unreadBadge = unreadBadge {
|
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?
|
let header:ChatListSearchItemHeader?
|
||||||
@ -415,7 +401,7 @@ enum ChatListSearchEntry: Comparable, Identifiable {
|
|||||||
|
|
||||||
var badge: ContactsPeerItemBadge?
|
var badge: ContactsPeerItemBadge?
|
||||||
if let unreadBadge = unreadBadge {
|
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?
|
let header:ChatListSearchItemHeader?
|
||||||
@ -649,7 +635,7 @@ final class ChatListSearchContainerNode: SearchDisplayControllerContentNode {
|
|||||||
|
|
||||||
let unreadCount = values.count(for: .peer(peerView.peerId))
|
let unreadCount = values.count(for: .peer(peerView.peerId))
|
||||||
if let unreadCount = unreadCount, unreadCount > 0 {
|
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)
|
return (peers: viewsAndPeers.1, unread: unread)
|
||||||
|
|||||||
@ -1,22 +1,11 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public enum UnreadSearchBadge: Equatable {
|
public struct UnreadSearchBadge: Equatable {
|
||||||
case muted(Int32)
|
public var unreadCount: Int32
|
||||||
case unmuted(Int32)
|
public var isMuted: Bool
|
||||||
|
|
||||||
public var count: Int32 {
|
public init(unreadCount: Int32, isMuted: Bool) {
|
||||||
switch self {
|
self.unreadCount = unreadCount
|
||||||
case let .muted(count), let .unmuted(count):
|
self.isMuted = isMuted
|
||||||
return count
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public var isMuted: Bool {
|
|
||||||
switch self {
|
|
||||||
case .muted:
|
|
||||||
return true
|
|
||||||
case .unmuted:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user