Skip to content

Commit

Permalink
Merge commit '240b5067c709e513f19ebbc6683ac9d5648facae' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
laktyushin committed Jan 6, 2024
2 parents f125591 + 240b506 commit f96ee41
Show file tree
Hide file tree
Showing 44 changed files with 204 additions and 660 deletions.
43 changes: 18 additions & 25 deletions submodules/AccountContext/Sources/AccountContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,34 +356,27 @@ public enum ChatSearchDomain: Equatable {
case everything
case members
case member(Peer)
case tag(String)

public static func ==(lhs: ChatSearchDomain, rhs: ChatSearchDomain) -> Bool {
switch lhs {
case .everything:
if case .everything = rhs {
return true
} else {
return false
}
case .members:
if case .members = rhs {
return true
} else {
return false
}
case let .member(lhsPeer):
if case let .member(rhsPeer) = rhs, lhsPeer.isEqual(rhsPeer) {
return true
} else {
return false
}
case let .tag(tag):
if case .tag(tag) = rhs {
return true
} else {
return false
}
case .everything:
if case .everything = rhs {
return true
} else {
return false
}
case .members:
if case .members = rhs {
return true
} else {
return false
}
case let .member(lhsPeer):
if case let .member(rhsPeer) = rhs, lhsPeer.isEqual(rhsPeer) {
return true
} else {
return false
}
}
}
}
Expand Down
20 changes: 0 additions & 20 deletions submodules/AvatarNode/Sources/AvatarNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public let repostStoryIcon = generateTintedImage(image: UIImage(bundleImageName:
private let archivedChatsIcon = UIImage(bundleImageName: "Avatar/ArchiveAvatarIcon")?.precomposed()
private let repliesIcon = generateTintedImage(image: UIImage(bundleImageName: "Avatar/RepliesMessagesIcon"), color: .white)
private let anonymousSavedMessagesIcon = generateTintedImage(image: UIImage(bundleImageName: "Avatar/AnonymousSenderIcon"), color: .white)
private let myNotesIcon = generateTintedImage(image: UIImage(bundleImageName: "Avatar/MyNotesIcon"), color: .white)

public func avatarPlaceholderFont(size: CGFloat) -> UIFont {
return Font.with(size: size, design: .round, weight: .bold)
Expand Down Expand Up @@ -96,8 +95,6 @@ private func calculateColors(context: AccountContext?, explicitColorIndex: Int?,
colors = AvatarNode.savedMessagesColors
} else if case .anonymousSavedMessagesIcon = icon {
colors = AvatarNode.savedMessagesColors
} else if case .myNotesIcon = icon {
colors = AvatarNode.savedMessagesColors
} else if case .editAvatarIcon = icon, let theme {
colors = [theme.list.itemAccentColor.withAlphaComponent(0.1), theme.list.itemAccentColor.withAlphaComponent(0.1)]
} else if case let .archivedChatsIcon(hiddenByDefault) = icon, let theme = theme {
Expand Down Expand Up @@ -179,7 +176,6 @@ private enum AvatarNodeIcon: Equatable {
case savedMessagesIcon
case repliesIcon
case anonymousSavedMessagesIcon
case myNotesIcon
case archivedChatsIcon(hiddenByDefault: Bool)
case editAvatarIcon
case deletedIcon
Expand All @@ -193,7 +189,6 @@ public enum AvatarNodeImageOverride: Equatable {
case savedMessagesIcon
case repliesIcon
case anonymousSavedMessagesIcon
case myNotesIcon
case archivedChatsIcon(hiddenByDefault: Bool)
case editAvatarIcon(forceNone: Bool)
case deletedIcon
Expand Down Expand Up @@ -497,9 +492,6 @@ public final class AvatarNode: ASDisplayNode {
case .anonymousSavedMessagesIcon:
representation = nil
icon = .anonymousSavedMessagesIcon
case .myNotesIcon:
representation = nil
icon = .myNotesIcon
case let .archivedChatsIcon(hiddenByDefault):
representation = nil
icon = .archivedChatsIcon(hiddenByDefault: hiddenByDefault)
Expand Down Expand Up @@ -670,9 +662,6 @@ public final class AvatarNode: ASDisplayNode {
case .anonymousSavedMessagesIcon:
representation = nil
icon = .anonymousSavedMessagesIcon
case .myNotesIcon:
representation = nil
icon = .myNotesIcon
case let .archivedChatsIcon(hiddenByDefault):
representation = nil
icon = .archivedChatsIcon(hiddenByDefault: hiddenByDefault)
Expand Down Expand Up @@ -912,15 +901,6 @@ public final class AvatarNode: ASDisplayNode {
if let anonymousSavedMessagesIcon = anonymousSavedMessagesIcon {
context.draw(anonymousSavedMessagesIcon.cgImage!, in: CGRect(origin: CGPoint(x: floor((bounds.size.width - anonymousSavedMessagesIcon.size.width) / 2.0), y: floor((bounds.size.height - anonymousSavedMessagesIcon.size.height) / 2.0)), size: anonymousSavedMessagesIcon.size))
}
} else if case .myNotesIcon = parameters.icon {
let factor = bounds.size.width / 60.0
context.translateBy(x: bounds.size.width / 2.0, y: bounds.size.height / 2.0)
context.scaleBy(x: factor, y: -factor)
context.translateBy(x: -bounds.size.width / 2.0, y: -bounds.size.height / 2.0)

if let myNotesIcon = myNotesIcon {
context.draw(myNotesIcon.cgImage!, in: CGRect(origin: CGPoint(x: floor((bounds.size.width - myNotesIcon.size.width) / 2.0), y: floor((bounds.size.height - myNotesIcon.size.height) / 2.0)), size: myNotesIcon.size))
}
} else if case .editAvatarIcon = parameters.icon, let theme = parameters.theme, !parameters.hasImage {
context.translateBy(x: bounds.size.width / 2.0, y: bounds.size.height / 2.0)
context.scaleBy(x: 1.0, y: -1.0)
Expand Down
24 changes: 7 additions & 17 deletions submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private enum ChatListRecentEntry: Comparable, Identifiable {
sortOrder: nameSortOrder,
displayOrder: nameDisplayOrder,
context: context,
peerMode: .generalSearch(isSavedMessages: false),
peerMode: .generalSearch,
peer: .peer(peer: primaryPeer, chatPeer: chatPeer),
status: status,
badge: badge,
Expand Down Expand Up @@ -508,7 +508,7 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
toggleExpandGlobalResults()
})

return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: .firstLast, displayOrder: .firstLast, context: context, peerMode: .generalSearch(isSavedMessages: false), peer: .thread(peer: peer, title: threadInfo.info.title, icon: threadInfo.info.icon, color: threadInfo.info.iconColor), status: .none, badge: nil, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: .firstLast, displayOrder: .firstLast, context: context, peerMode: .generalSearch, peer: .thread(peer: peer, title: threadInfo.info.title, icon: threadInfo.info.icon, color: threadInfo.info.iconColor), status: .none, badge: nil, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in
interaction.peerSelected(peer, nil, threadInfo.id, nil)
}, contextAction: nil, animationCache: interaction.animationCache, animationRenderer: interaction.animationRenderer)
case let .recentlySearchedPeer(peer, associatedPeer, unreadBadge, _, theme, strings, nameSortOrder, nameDisplayOrder, storyStats):
Expand Down Expand Up @@ -572,7 +572,7 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
header = ChatListSearchItemHeader(type: headerType, theme: theme, strings: strings, actionTitle: nil, action: nil)
}

return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch(isSavedMessages: false), peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: .none, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: .none, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in
if case let .peer(maybePeer, maybeChatPeer) = contactPeer, let peer = maybePeer, let chatPeer = maybeChatPeer {
interaction.peerSelected(chatPeer, peer, nil, nil)
} else {
Expand Down Expand Up @@ -671,12 +671,8 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
toggleExpandLocalResults()
})
}
var isSavedMessages = false
if case .savedMessagesChats = location {
isSavedMessages = true
}

return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch(isSavedMessages: isSavedMessages), peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: .none, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: .none, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in
if case let .peer(maybePeer, maybeChatPeer) = contactPeer, let peer = maybePeer, let chatPeer = maybeChatPeer {
interaction.peerSelected(chatPeer, peer, nil, nil)
} else {
Expand Down Expand Up @@ -751,13 +747,8 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
toggleExpandGlobalResults()
})
}

var isSavedMessages = false
if case .savedMessagesChats = location {
isSavedMessages = true
}

return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch(isSavedMessages: isSavedMessages), peer: .peer(peer: EnginePeer(peer.peer), chatPeer: EnginePeer(peer.peer)), status: .addressName(suffixString), badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: EnginePeer(peer.peer), chatPeer: EnginePeer(peer.peer)), status: .addressName(suffixString), badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in
interaction.peerSelected(EnginePeer(peer.peer), nil, nil, nil)
}, contextAction: peerContextAction.flatMap { peerContextAction in
return { node, gesture, location in
Expand Down Expand Up @@ -1423,9 +1414,8 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
if let query {
foundLocalPeers = context.engine.messages.searchLocalSavedMessagesPeers(query: query.lowercased(), indexNameMapping: [
context.account.peerId: [
PeerIndexNameRepresentation.title(title: "my notes", addressNames: []),
//TODO:localize
PeerIndexNameRepresentation.title(title: "my notes".lowercased(), addressNames: [])
PeerIndexNameRepresentation.title(title: "saved messages", addressNames: []),
PeerIndexNameRepresentation.title(title: presentationData.strings.DialogList_SavedMessages.lowercased(), addressNames: [])
],
PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(2666000)): [
PeerIndexNameRepresentation.title(title: presentationData.strings.ChatList_AuthorHidden.lowercased(), addressNames: [])
Expand Down
16 changes: 3 additions & 13 deletions submodules/ChatListUI/Sources/Node/ChatListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1406,11 +1406,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
} else if peer.id.isAnonymousSavedMessages {
overrideImage = .anonymousSavedMessagesIcon
} else if peer.id == item.context.account.peerId && !displayAsMessage {
if case .savedMessagesChats = item.chatListLocation {
overrideImage = .myNotesIcon
} else {
overrideImage = .savedMessagesIcon
}
overrideImage = .savedMessagesIcon
} else if peer.isDeleted {
overrideImage = .deletedIcon
}
Expand Down Expand Up @@ -2306,12 +2302,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
} else if isPeerGroup {
titleAttributedString = NSAttributedString(string: item.presentationData.strings.ChatList_ArchivedChatsTitle, font: titleFont, textColor: theme.titleColor)
} else if itemPeer.chatMainPeer?.id == item.context.account.peerId {
if case .savedMessagesChats = item.chatListLocation {
//TODO:localize
titleAttributedString = NSAttributedString(string: "My Notes", font: titleFont, textColor: theme.titleColor)
} else {
titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_SavedMessages, font: titleFont, textColor: theme.titleColor)
}
titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_SavedMessages, font: titleFont, textColor: theme.titleColor)
} else if let id = itemPeer.chatMainPeer?.id, id.isReplies {
titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_Replies, font: titleFont, textColor: theme.titleColor)
} else if let id = itemPeer.chatMainPeer?.id, id.isAnonymousSavedMessages {
Expand Down Expand Up @@ -2617,8 +2608,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {

var isFirstForumThreadSelectable = false
var forumThreads: [(id: Int64, title: NSAttributedString, iconId: Int64?, iconColor: Int32)] = []
if case .savedMessagesChats = item.chatListLocation {
} else if forumThread != nil || !topForumTopicItems.isEmpty {
if forumThread != nil || !topForumTopicItems.isEmpty {
if let forumThread = forumThread {
isFirstForumThreadSelectable = forumThread.isUnread
forumThreads.append((id: forumThread.id, title: NSAttributedString(string: forumThread.title, font: textFont, textColor: forumThread.isUnread || isSearching ? theme.authorNameColor : theme.messageTextColor), iconId: forumThread.iconId, iconColor: forumThread.iconColor))
Expand Down
12 changes: 6 additions & 6 deletions submodules/ChatListUI/Sources/Node/ChatListNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
sortOrder: presentationData.nameSortOrder,
displayOrder: presentationData.nameDisplayOrder,
context: context,
peerMode: .generalSearch(isSavedMessages: false),
peerMode: .generalSearch,
peer: peerContent,
status: status,
enabled: enabled,
Expand Down Expand Up @@ -619,7 +619,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
sortOrder: presentationData.nameSortOrder,
displayOrder: presentationData.nameDisplayOrder,
context: context,
peerMode: .generalSearch(isSavedMessages: false),
peerMode: .generalSearch,
peer: peerContent,
status: status,
enabled: true,
Expand Down Expand Up @@ -681,7 +681,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
sortOrder: presentationData.nameSortOrder,
displayOrder: presentationData.nameDisplayOrder,
context: context,
peerMode: .generalSearch(isSavedMessages: false),
peerMode: .generalSearch,
peer: peerContent,
status: status,
enabled: true,
Expand Down Expand Up @@ -899,7 +899,7 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
sortOrder: presentationData.nameSortOrder,
displayOrder: presentationData.nameDisplayOrder,
context: context,
peerMode: .generalSearch(isSavedMessages: false),
peerMode: .generalSearch,
peer: peerContent,
status: status,
enabled: enabled,
Expand Down Expand Up @@ -938,7 +938,7 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
sortOrder: presentationData.nameSortOrder,
displayOrder: presentationData.nameDisplayOrder,
context: context,
peerMode: .generalSearch(isSavedMessages: false),
peerMode: .generalSearch,
peer: peerContent,
status: status,
enabled: true,
Expand Down Expand Up @@ -1000,7 +1000,7 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
sortOrder: presentationData.nameSortOrder,
displayOrder: presentationData.nameDisplayOrder,
context: context,
peerMode: .generalSearch(isSavedMessages: false),
peerMode: .generalSearch,
peer: peerContent,
status: status,
enabled: true,
Expand Down
1 change: 0 additions & 1 deletion submodules/Components/ReactionButtonListComponent/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ swift_library(
"//submodules/TelegramUI/Components/AnimationCache:AnimationCache",
"//submodules/TelegramUI/Components/MultiAnimationRenderer:MultiAnimationRenderer",
"//submodules/TextFormat:TextFormat",
"//submodules/AppBundle",
],
visibility = [
"//visibility:public",
Expand Down
Loading

0 comments on commit f96ee41

Please sign in to comment.