Skip to content

Commit 44f02c2

Browse files
committed
Various fixes
1 parent 10984d7 commit 44f02c2

File tree

36 files changed

+278
-107
lines changed

36 files changed

+278
-107
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13290,5 +13290,10 @@ Sorry for the inconvenience.";
1329013290
"MediaGallery.ToastVideoPip.Title" = "Video Minimized";
1329113291
"MediaGallery.ToastVideoPip.Text" = "Swipe down on a video to close it.";
1329213292

13293-
"Chat.ToastSubscribedToScheduledLiveStream.Text" = "You will be notified when the liver stream starts.";
13293+
"Chat.ToastSubscribedToScheduledLiveStream.Text" = "You will be notified when the live stream starts.";
1329413294
"Chat.TitleVideochatPanel.NotifyScheduledButton" = "Notify Me";
13295+
13296+
"WebApp.ShareMessage.Title" = "Share Message";
13297+
"WebApp.ShareMessage.PreviewTitle" = "MESSAGE PREVIEW";
13298+
"WebApp.ShareMessage.Info" = "%@ mini app suggests you to send this message to a chat you select.";
13299+
"WebApp.ShareMessage.Share" = "Share With...";

submodules/AccountContext/Sources/AccountContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ public protocol SharedAccountContext: AnyObject {
10001000

10011001
func makeStarsGiftController(context: AccountContext, birthdays: [EnginePeer.Id: TelegramBirthday]?, completion: @escaping (([EnginePeer.Id]) -> Void)) -> ViewController
10021002
func makePremiumGiftController(context: AccountContext, source: PremiumGiftSource, completion: (([EnginePeer.Id]) -> Void)?) -> ViewController
1003-
func makeGiftOptionsController(context: AccountContext, peerId: EnginePeer.Id, premiumOptions: [CachedPremiumGiftOption]) -> ViewController
1003+
func makeGiftOptionsController(context: AccountContext, peerId: EnginePeer.Id, premiumOptions: [CachedPremiumGiftOption], hasBirthday: Bool) -> ViewController
10041004
func makePremiumPrivacyControllerController(context: AccountContext, subject: PremiumPrivacySubject, peerId: EnginePeer.Id) -> ViewController
10051005
func makePremiumBoostLevelsController(context: AccountContext, peerId: EnginePeer.Id, subject: BoostSubject, boostStatus: ChannelBoostStatus, myBoostStatus: MyBoostStatus, forceDark: Bool, openStats: (() -> Void)?) -> ViewController
10061006

submodules/ChatListUI/Sources/ChatListController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,12 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
12561256
}
12571257
}
12581258

1259+
self.chatListDisplayNode.dismissSearch = { [weak self] in
1260+
if let self {
1261+
self.deactivateSearch(animated: true)
1262+
}
1263+
}
1264+
12591265
self.chatListDisplayNode.requestOpenRecentPeerOptions = { [weak self] peer in
12601266
if let strongSelf = self {
12611267
strongSelf.view.window?.endEditing(true)

submodules/ChatListUI/Sources/ChatListControllerNode.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,8 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
10951095
var isEmptyUpdated: ((Bool) -> Void)?
10961096
var emptyListAction: ((EnginePeer.Id?) -> Void)?
10971097
var cancelEditing: (() -> Void)?
1098-
1098+
var dismissSearch: (() -> Void)?
1099+
10991100
let debugListView = ListView()
11001101

11011102
init(context: AccountContext, location: ChatListControllerLocation, previewing: Bool, controlsHistoryPreload: Bool, presentationData: PresentationData, animationCache: AnimationCache, animationRenderer: MultiAnimationRenderer, controller: ChatListControllerImpl) {
@@ -1668,6 +1669,9 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
16681669
}, navigationController: navigationController, parentController: { [weak self] in
16691670
return self?.controller
16701671
})
1672+
contentNode.dismissSearch = { [weak self] in
1673+
self?.dismissSearch?()
1674+
}
16711675

16721676
self.searchDisplayController = SearchDisplayController(presentationData: self.presentationData, mode: .list, contentNode: contentNode, cancel: { [weak self] in
16731677
if let requestDeactivateSearch = self?.requestDeactivateSearch {

submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ final class ChatListSearchInteraction {
6161
let getSelectedMessageIds: () -> Set<EngineMessage.Id>?
6262
let openStories: ((PeerId, ASDisplayNode) -> Void)?
6363
let switchToFilter: (ChatListSearchPaneKey) -> Void
64+
let dismissSearch: () -> Void
6465

65-
init(openPeer: @escaping (EnginePeer, EnginePeer?, Int64?, Bool) -> Void, openDisabledPeer: @escaping (EnginePeer, Int64?, ChatListDisabledPeerReason) -> Void, openMessage: @escaping (EnginePeer, Int64?, EngineMessage.Id, Bool) -> Void, openUrl: @escaping (String) -> Void, clearRecentSearch: @escaping () -> Void, addContact: @escaping (String) -> Void, toggleMessageSelection: @escaping (EngineMessage.Id, Bool) -> Void, messageContextAction: @escaping ((EngineMessage, ASDisplayNode?, CGRect?, UIGestureRecognizer?, ChatListSearchPaneKey, (id: String, size: Int64, isFirstInList: Bool)?) -> Void), mediaMessageContextAction: @escaping ((EngineMessage, ASDisplayNode?, CGRect?, UIGestureRecognizer?) -> Void), peerContextAction: ((EnginePeer, ChatListSearchContextActionSource, ASDisplayNode, ContextGesture?, CGPoint?) -> Void)?, present: @escaping (ViewController, Any?) -> Void, dismissInput: @escaping () -> Void, getSelectedMessageIds: @escaping () -> Set<EngineMessage.Id>?, openStories: ((PeerId, ASDisplayNode) -> Void)?, switchToFilter: @escaping (ChatListSearchPaneKey) -> Void) {
66+
init(openPeer: @escaping (EnginePeer, EnginePeer?, Int64?, Bool) -> Void, openDisabledPeer: @escaping (EnginePeer, Int64?, ChatListDisabledPeerReason) -> Void, openMessage: @escaping (EnginePeer, Int64?, EngineMessage.Id, Bool) -> Void, openUrl: @escaping (String) -> Void, clearRecentSearch: @escaping () -> Void, addContact: @escaping (String) -> Void, toggleMessageSelection: @escaping (EngineMessage.Id, Bool) -> Void, messageContextAction: @escaping ((EngineMessage, ASDisplayNode?, CGRect?, UIGestureRecognizer?, ChatListSearchPaneKey, (id: String, size: Int64, isFirstInList: Bool)?) -> Void), mediaMessageContextAction: @escaping ((EngineMessage, ASDisplayNode?, CGRect?, UIGestureRecognizer?) -> Void), peerContextAction: ((EnginePeer, ChatListSearchContextActionSource, ASDisplayNode, ContextGesture?, CGPoint?) -> Void)?, present: @escaping (ViewController, Any?) -> Void, dismissInput: @escaping () -> Void, getSelectedMessageIds: @escaping () -> Set<EngineMessage.Id>?, openStories: ((PeerId, ASDisplayNode) -> Void)?, switchToFilter: @escaping (ChatListSearchPaneKey) -> Void, dismissSearch: @escaping () -> Void) {
6667
self.openPeer = openPeer
6768
self.openDisabledPeer = openDisabledPeer
6869
self.openMessage = openMessage
@@ -78,6 +79,7 @@ final class ChatListSearchInteraction {
7879
self.getSelectedMessageIds = getSelectedMessageIds
7980
self.openStories = openStories
8081
self.switchToFilter = switchToFilter
82+
self.dismissSearch = dismissSearch
8183
}
8284
}
8385

@@ -100,6 +102,8 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
100102
private let openMessage: (EnginePeer, Int64?, EngineMessage.Id, Bool) -> Void
101103
private let navigationController: NavigationController?
102104

105+
var dismissSearch: (() -> Void)?
106+
103107
private let dimNode: ASDisplayNode
104108
let filterContainerNode: ChatListSearchFiltersContainerNode
105109
private let paneContainerNode: ChatListSearchPaneContainerNode
@@ -298,6 +302,8 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
298302
Queue.mainQueue().justDispatch {
299303
self.paneContainerNode.requestSelectPane(filter)
300304
}
305+
}, dismissSearch: { [weak self] in
306+
self?.dismissSearch?()
301307
})
302308
self.paneContainerNode.interaction = interaction
303309

submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
614614
})
615615

616616
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
617-
interaction.peerSelected(peer, nil, threadInfo.id, nil)
617+
interaction.peerSelected(peer, nil, threadInfo.id, nil, false)
618618
}, contextAction: nil, animationCache: interaction.animationCache, animationRenderer: interaction.animationRenderer)
619619
case let .recentlySearchedPeer(peer, associatedPeer, unreadBadge, _, theme, strings, nameSortOrder, nameDisplayOrder, storyStats, requiresPremiumForMessaging):
620620
let primaryPeer: EnginePeer
@@ -667,6 +667,7 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
667667
badge = ContactsPeerItemBadge(count: unreadBadge.0, type: unreadBadge.1 ? .inactive : .active)
668668
}
669669

670+
var buttonAction: ContactsPeerItemButtonAction?
670671
let header: ChatListSearchItemHeader?
671672
if filter.contains(.removeSearchHeader) {
672673
header = nil
@@ -676,15 +677,24 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
676677
headerType = .chats
677678
} else {
678679
headerType = .recentPeers
680+
681+
if case .chats = key, case let .user(user) = primaryPeer, let botInfo = user.botInfo, botInfo.flags.contains(.hasWebApp) {
682+
buttonAction = ContactsPeerItemButtonAction(
683+
title: presentationData.strings.ChatList_Search_Open,
684+
action: { peer, _, _ in
685+
interaction.peerSelected(primaryPeer, nil, nil, nil, true)
686+
}
687+
)
688+
}
679689
}
680690
header = ChatListSearchItemHeader(type: headerType, theme: theme, strings: strings, actionTitle: nil, action: nil)
681691
}
682-
683-
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, requiresPremiumForMessaging: requiresPremiumForMessaging, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in
692+
693+
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, requiresPremiumForMessaging: requiresPremiumForMessaging, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), buttonAction: buttonAction, index: nil, header: header, action: { contactPeer in
684694
if case let .peer(maybePeer, maybeChatPeer) = contactPeer, let peer = maybePeer, let chatPeer = maybeChatPeer {
685-
interaction.peerSelected(chatPeer, peer, nil, nil)
695+
interaction.peerSelected(chatPeer, peer, nil, nil, false)
686696
} else {
687-
interaction.peerSelected(peer, nil, nil, nil)
697+
interaction.peerSelected(peer, nil, nil, nil, false)
688698
}
689699
}, disabledAction: { _ in
690700
interaction.disabledPeerSelected(peer, nil, requiresPremiumForMessaging ? .premiumRequired : .generic)
@@ -803,12 +813,22 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
803813
status = .custom(string: presentationData.strings.Bot_GenericBotStatus, multiline: false, isActive: false, icon: nil)
804814
}
805815
}
816+
817+
var buttonAction: ContactsPeerItemButtonAction?
818+
if case .chats = key, case let .user(user) = primaryPeer, let botInfo = user.botInfo, botInfo.flags.contains(.hasWebApp) {
819+
buttonAction = ContactsPeerItemButtonAction(
820+
title: presentationData.strings.ChatList_Search_Open,
821+
action: { peer, _, _ in
822+
interaction.peerSelected(primaryPeer, nil, nil, nil, true)
823+
}
824+
)
825+
}
806826

807-
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch(isSavedMessages: isSavedMessages), peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: status, badge: badge, requiresPremiumForMessaging: requiresPremiumForMessaging, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in
827+
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch(isSavedMessages: isSavedMessages), peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: status, badge: badge, requiresPremiumForMessaging: requiresPremiumForMessaging, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), buttonAction: buttonAction, index: nil, header: header, action: { contactPeer in
808828
if case let .peer(maybePeer, maybeChatPeer) = contactPeer, let peer = maybePeer, let chatPeer = maybeChatPeer {
809-
interaction.peerSelected(chatPeer, peer, nil, nil)
829+
interaction.peerSelected(chatPeer, peer, nil, nil, false)
810830
} else {
811-
interaction.peerSelected(peer, nil, nil, nil)
831+
interaction.peerSelected(peer, nil, nil, nil, false)
812832
}
813833
}, disabledAction: { _ in
814834
interaction.disabledPeerSelected(peer, nil, requiresPremiumForMessaging ? .premiumRequired : .generic)
@@ -891,7 +911,7 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
891911
}
892912

893913
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, requiresPremiumForMessaging: requiresPremiumForMessaging, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, searchQuery: query, action: { _ in
894-
interaction.peerSelected(EnginePeer(peer.peer), nil, nil, nil)
914+
interaction.peerSelected(EnginePeer(peer.peer), nil, nil, nil, false)
895915
}, disabledAction: { _ in
896916
interaction.disabledPeerSelected(EnginePeer(peer.peer), nil, requiresPremiumForMessaging ? .premiumRequired : .generic)
897917
}, contextAction: peerContextAction.flatMap { peerContextAction in
@@ -2883,9 +2903,29 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
28832903
}
28842904

28852905
let chatListInteraction = ChatListNodeInteraction(context: context, animationCache: self.animationCache, animationRenderer: self.animationRenderer, activateSearch: {
2886-
}, peerSelected: { [weak self] peer, chatPeer, threadId, _ in
2906+
}, peerSelected: { [weak self] peer, chatPeer, threadId, _, openApp in
28872907
interaction.dismissInput()
2888-
interaction.openPeer(peer, chatPeer, threadId, false)
2908+
if openApp, let self {
2909+
if case let .user(user) = peer, let botInfo = user.botInfo, botInfo.flags.contains(.hasWebApp), let parentController = self.parentController {
2910+
context.sharedContext.openWebApp(
2911+
context: context,
2912+
parentController: parentController,
2913+
updatedPresentationData: nil,
2914+
botPeer: peer,
2915+
chatPeer: nil,
2916+
threadId: nil,
2917+
buttonText: "",
2918+
url: "",
2919+
simple: true,
2920+
source: .generic,
2921+
skipTermsOfService: true,
2922+
payload: nil
2923+
)
2924+
interaction.dismissSearch()
2925+
}
2926+
} else {
2927+
interaction.openPeer(peer, chatPeer, threadId, false)
2928+
}
28892929
switch location {
28902930
case .chatList, .forum:
28912931
let _ = context.engine.peers.addRecentlySearchedPeer(peerId: peer.id).startStandalone()
@@ -3851,6 +3891,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
38513891
skipTermsOfService: true,
38523892
payload: nil
38533893
)
3894+
interaction.dismissSearch()
38543895
} else {
38553896
interaction.openPeer(peer, nil, threadId, true)
38563897
}
@@ -4853,7 +4894,7 @@ public final class ChatListSearchShimmerNode: ASDisplayNode {
48534894
let timestamp1: Int32 = 100000
48544895
var peers: [EnginePeer.Id: EnginePeer] = [:]
48554896
peers[peer1.id] = peer1
4856-
let interaction = ChatListNodeInteraction(context: context, animationCache: animationCache, animationRenderer: animationRenderer, activateSearch: {}, peerSelected: { _, _, _, _ in }, disabledPeerSelected: { _, _, _ in }, togglePeerSelected: { _, _ in }, togglePeersSelection: { _, _ in }, additionalCategorySelected: { _ in
4897+
let interaction = ChatListNodeInteraction(context: context, animationCache: animationCache, animationRenderer: animationRenderer, activateSearch: {}, peerSelected: { _, _, _, _, _ in }, disabledPeerSelected: { _, _, _ in }, togglePeerSelected: { _, _ in }, togglePeersSelection: { _, _ in }, additionalCategorySelected: { _ in
48574898
}, messageSelected: { _, _, _, _ in}, groupSelected: { _ in }, addContact: { _ in }, setPeerIdWithRevealedOptions: { _, _ in }, setItemPinned: { _, _ in }, setPeerMuted: { _, _ in }, setPeerThreadMuted: { _, _, _ in }, deletePeer: { _, _ in }, deletePeerThread: { _, _ in }, setPeerThreadStopped: { _, _, _ in }, setPeerThreadPinned: { _, _, _ in }, setPeerThreadHidden: { _, _, _ in }, updatePeerGrouping: { _, _ in }, togglePeerMarkedUnread: { _, _ in}, toggleArchivedFolderHiddenByDefault: {}, toggleThreadsSelection: { _, _ in }, hidePsa: { _ in }, activateChatPreview: { _, _, _, gesture, _ in
48584899
gesture?.cancel()
48594900
}, present: { _ in }, openForumThread: { _, _ in }, openStorageManagement: {}, openPasswordSetup: {}, openPremiumIntro: {}, openPremiumGift: { _, _ in }, openPremiumManagement: {}, openActiveSessions: {

0 commit comments

Comments
 (0)