mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Refactoring
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
@@ -14,7 +13,7 @@ private enum MessageGroupType {
|
||||
case generic
|
||||
}
|
||||
|
||||
private func singleMessageType(message: Message) -> MessageGroupType {
|
||||
private func singleMessageType(message: EngineMessage) -> MessageGroupType {
|
||||
for media in message.media {
|
||||
if let _ = media as? TelegramMediaImage {
|
||||
return .photos
|
||||
@@ -31,7 +30,7 @@ private func singleMessageType(message: Message) -> MessageGroupType {
|
||||
return .generic
|
||||
}
|
||||
|
||||
private func messageGroupType(messages: [Message]) -> MessageGroupType {
|
||||
private func messageGroupType(messages: [EngineMessage]) -> MessageGroupType {
|
||||
if messages.isEmpty {
|
||||
return .generic
|
||||
}
|
||||
@@ -45,16 +44,16 @@ private func messageGroupType(messages: [Message]) -> MessageGroupType {
|
||||
return currentType
|
||||
}
|
||||
|
||||
public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, dateTimeFormat: PresentationDateTimeFormat, messages: [Message], chatPeer: RenderedPeer, accountPeerId: PeerId, enableMediaEmoji: Bool = true, isPeerGroup: Bool = false) -> (peer: Peer?, hideAuthor: Bool, messageText: String) {
|
||||
let peer: Peer?
|
||||
public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, dateTimeFormat: PresentationDateTimeFormat, messages: [EngineMessage], chatPeer: EngineRenderedPeer, accountPeerId: EnginePeer.Id, enableMediaEmoji: Bool = true, isPeerGroup: Bool = false) -> (peer: EnginePeer?, hideAuthor: Bool, messageText: String) {
|
||||
let peer: EnginePeer?
|
||||
|
||||
let message = messages.last
|
||||
|
||||
var hideAuthor = false
|
||||
var messageText: String
|
||||
if let message = message {
|
||||
if let messageMain = messageMainPeer(EngineMessage(message)) {
|
||||
peer = messageMain._asPeer()
|
||||
if let messageMain = messageMainPeer(message) {
|
||||
peer = messageMain
|
||||
} else {
|
||||
peer = chatPeer.chatMainPeer
|
||||
}
|
||||
@@ -261,12 +260,12 @@ public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder:
|
||||
}
|
||||
default:
|
||||
hideAuthor = true
|
||||
if let text = plainServiceMessageString(strings: strings, nameDisplayOrder: nameDisplayOrder, dateTimeFormat: dateTimeFormat, message: EngineMessage(message), accountPeerId: accountPeerId, forChatList: true) {
|
||||
if let text = plainServiceMessageString(strings: strings, nameDisplayOrder: nameDisplayOrder, dateTimeFormat: dateTimeFormat, message: message, accountPeerId: accountPeerId, forChatList: true) {
|
||||
messageText = text
|
||||
}
|
||||
}
|
||||
case _ as TelegramMediaExpiredContent:
|
||||
if let text = plainServiceMessageString(strings: strings, nameDisplayOrder: nameDisplayOrder, dateTimeFormat: dateTimeFormat, message: EngineMessage(message), accountPeerId: accountPeerId, forChatList: true) {
|
||||
if let text = plainServiceMessageString(strings: strings, nameDisplayOrder: nameDisplayOrder, dateTimeFormat: dateTimeFormat, message: message, accountPeerId: accountPeerId, forChatList: true) {
|
||||
messageText = text
|
||||
}
|
||||
case let poll as TelegramMediaPoll:
|
||||
@@ -282,21 +281,21 @@ public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder:
|
||||
peer = chatPeer.chatMainPeer
|
||||
messageText = ""
|
||||
if chatPeer.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
if let secretChat = chatPeer.peers[chatPeer.peerId] as? TelegramSecretChat {
|
||||
if case let .secretChat(secretChat) = chatPeer.peers[chatPeer.peerId] {
|
||||
switch secretChat.embeddedState {
|
||||
case .active:
|
||||
switch secretChat.role {
|
||||
case .creator:
|
||||
messageText = strings.DialogList_EncryptedChatStartedOutgoing(peer.flatMap(EnginePeer.init)?.compactDisplayTitle ?? "").string
|
||||
messageText = strings.DialogList_EncryptedChatStartedOutgoing(peer?.compactDisplayTitle ?? "").string
|
||||
case .participant:
|
||||
messageText = strings.DialogList_EncryptedChatStartedIncoming(peer.flatMap(EnginePeer.init)?.compactDisplayTitle ?? "").string
|
||||
messageText = strings.DialogList_EncryptedChatStartedIncoming(peer?.compactDisplayTitle ?? "").string
|
||||
}
|
||||
case .terminated:
|
||||
messageText = strings.DialogList_EncryptionRejected
|
||||
case .handshake:
|
||||
switch secretChat.role {
|
||||
case .creator:
|
||||
messageText = strings.DialogList_AwaitingEncryption(peer.flatMap(EnginePeer.init)?.compactDisplayTitle ?? "").string
|
||||
messageText = strings.DialogList_AwaitingEncryption(peer?.compactDisplayTitle ?? "").string
|
||||
case .participant:
|
||||
messageText = strings.DialogList_EncryptionProcessing
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user