Skip to content

Commit 5761556

Browse files
committed
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
2 parents 1496c81 + cfd7a52 commit 5761556

File tree

40 files changed

+1509
-817
lines changed

40 files changed

+1509
-817
lines changed

.vscode/launch.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
"internalConsoleOptions": "openOnSessionStart",
1313
"timeout": 1000
1414
},
15+
{
16+
"name": "Restart Debug Telegram",
17+
"type": "lldb-dap",
18+
"request": "attach",
19+
"preLaunchTask": "Restart Telegram Debug",
20+
"debuggerRoot": "${workspaceFolder}",
21+
"attachCommands": [
22+
"process connect connect://localhost:6667"
23+
],
24+
"internalConsoleOptions": "openOnSessionStart",
25+
"timeout": 1000
26+
},
1527
],
1628
"options": {
1729
"console": "integratedTerminal",

.vscode/tasks.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"label": "Build Telegram",
66
"type": "shell",
7-
"command": "${workspaceFolder}/build-input/bazel-8.3.1-darwin-arm64",
7+
"command": "${workspaceFolder}/build-input/bazel-8.4.2-darwin-arm64",
88
"args": [
99
"build",
1010
"Telegram/Telegram",
@@ -74,6 +74,28 @@
7474
"reveal": "always",
7575
"panel": "dedicated"
7676
}
77+
},
78+
{
79+
"label": "Stop Telegram Debug Session",
80+
"type": "shell",
81+
"command": "pkill -f 'launch_and_debug.sh' || true; lsof -ti:6667 | xargs kill -9 2>/dev/null || true",
82+
"problemMatcher": [],
83+
"presentation": {
84+
"reveal": "silent",
85+
"close": true
86+
}
87+
},
88+
{
89+
"label": "Restart Telegram Debug",
90+
"dependsOrder": "sequence",
91+
"dependsOn": [
92+
"Stop Telegram Debug Session",
93+
"_launch_telegram"
94+
],
95+
"problemMatcher": [],
96+
"presentation": {
97+
"reveal": "always"
98+
}
7799
}
78100
]
79101
}

BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load("@sourcekit_bazel_bsp//rules:setup_sourcekit_bsp.bzl", "setup_sourcekit_bsp
22

33
setup_sourcekit_bsp(
44
name = "setup_sourcekit_bsp_telegram_project",
5-
bazel_wrapper = "./build-input/bazel-8.3.1-darwin-arm64",
5+
bazel_wrapper = "./build-input/bazel-8.4.2-darwin-arm64",
66
files_to_watch = [
77
"**/*.swift",
88
],

MODULE.bazel.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Telegram/BUILD

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ load("@build_bazel_rules_apple//apple:ios.bzl",
88
"ios_application",
99
"ios_extension",
1010
"ios_framework",
11-
"ios_unit_test",
12-
"ios_ui_test",
1311
)
1412

1513
load("@build_bazel_rules_apple//apple:resources.bzl",
@@ -22,7 +20,6 @@ load("@build_bazel_rules_swift//swift:swift.bzl",
2220

2321
load(
2422
"@rules_xcodeproj//xcodeproj:defs.bzl",
25-
"top_level_target",
2623
"top_level_targets",
2724
"xcodeproj",
2825
"xcode_provisioning_profile",

scripts/launch_and_debug.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -e
77
# Ideally we should upstream these changes back to rules_apple since they should be useful for everyone.
88

99
echo "Building..."
10-
./build-input/bazel-8.3.1-darwin-arm64 build Telegram/Telegram --announce_rc --features=swift.use_global_module_cache --verbose_failures --remote_cache_async --features=swift.skip_function_bodies_for_derived_files --jobs=16 --define=buildNumber=10000 --define=telegramVersion=12.2.1 --disk_cache=/Users/ali/telegram-bazel-cache -c dbg --ios_multi_cpus=sim_arm64 --watchos_cpus=arm64_32 --features=swift.enable_batch_mode
10+
./build-input/bazel-8.4.2-darwin-arm64 build Telegram/Telegram --announce_rc --features=swift.use_global_module_cache --verbose_failures --remote_cache_async --jobs=16 --define=buildNumber=10000 --define=telegramVersion=12.2.1 --disk_cache=/Users/ali/telegram-bazel-cache -c dbg --ios_multi_cpus=sim_arm64 --watchos_cpus=arm64_32 --features=swift.enable_batch_mode
1111
chmod -R 777 ./bazel-bin/Telegram
1212

1313
tmp_file=$(pwd)/bazel-bin/Telegram/pid.txt

submodules/CallListUI/Sources/CallListController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ public final class CallListController: TelegramBaseController {
155155
if case .navigation = self.mode {
156156
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Back, style: .plain, target: nil, action: nil)
157157
}
158+
159+
self.updateTabBarSearchState(ViewController.TabBarSearchState(isActive: false), transition: .immediate)
158160
}
159161

160162
required public init(coder aDecoder: NSCoder) {

submodules/ChatListUI/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ swift_library(
118118
"//submodules/TelegramUI/Components/ButtonComponent",
119119
"//submodules/TelegramUI/Components/AnimatedTextComponent",
120120
"//submodules/TelegramUI/Components/EdgeEffect",
121+
"//submodules/TelegramUI/Components/ChatList/ChatListFilterTabContainerNode",
121122
],
122123
visibility = [
123124
"//visibility:public",

submodules/ChatListUI/Sources/ChatListController.swift

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ import TextFormat
5555
import AvatarUploadToastScreen
5656
import AdsInfoScreen
5757
import AdsReportScreen
58+
import SearchBarNode
59+
import ChatListFilterTabContainerNode
5860

5961
private final class ContextControllerContentSourceImpl: ContextControllerContentSource {
6062
let controller: ViewController
@@ -768,6 +770,8 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
768770
})
769771

770772
self.updateNavigationMetadata()
773+
774+
self.updateTabBarSearchState(ViewController.TabBarSearchState(isActive: false), transition: .immediate)
771775
}
772776

773777
required public init(coder aDecoder: NSCoder) {
@@ -2838,14 +2842,9 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
28382842
func updateHeaderContent() -> (primaryContent: ChatListHeaderComponent.Content?, secondaryContent: ChatListHeaderComponent.Content?) {
28392843
var primaryContent: ChatListHeaderComponent.Content?
28402844
if let primaryContext = self.primaryContext {
2841-
var backTitle: String?
2842-
if let previousItem = self.previousItem {
2843-
switch previousItem {
2844-
case let .item(item):
2845-
backTitle = item.title ?? self.presentationData.strings.Common_Back
2846-
case .close:
2847-
backTitle = self.presentationData.strings.Common_Close
2848-
}
2845+
var displayBackButton: Bool = false
2846+
if self.previousItem != nil {
2847+
displayBackButton = true
28492848
}
28502849
var navigationBackTitle: String?
28512850
if case .chatList(.archive) = self.location {
@@ -2858,8 +2857,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
28582857
chatListTitle: primaryContext.chatListTitle,
28592858
leftButton: primaryContext.leftButton,
28602859
rightButtons: primaryContext.rightButtons,
2861-
backTitle: backTitle,
2862-
backPressed: backTitle != nil ? { [weak self] in
2860+
backPressed: displayBackButton ? { [weak self] in
28632861
guard let self else {
28642862
return
28652863
}
@@ -2876,7 +2874,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
28762874
chatListTitle: secondaryContext.chatListTitle,
28772875
leftButton: secondaryContext.leftButton,
28782876
rightButtons: secondaryContext.rightButtons,
2879-
backTitle: nil,
28802877
backPressed: { [weak self] in
28812878
guard let self else {
28822879
return
@@ -4638,9 +4635,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
46384635
searchContentNode = navigationBarView.searchContentNode
46394636
}
46404637

4641-
if let searchContentNode {
4642-
self.activateSearch(filter: filter, query: query, skipScrolling: false, searchContentNode: searchContentNode)
4643-
}
4638+
self.activateSearch(filter: filter, query: query, skipScrolling: false, searchContentNode: searchContentNode)
46444639
}
46454640

46464641
public func activateSearch(query: String? = nil) {
@@ -4654,45 +4649,37 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
46544649
}
46554650

46564651
private var previousSearchToggleTimestamp: Double?
4657-
func activateSearch(filter: ChatListSearchFilter = .chats, query: String? = nil, skipScrolling: Bool = false, searchContentNode: NavigationBarSearchContentNode) {
4658-
let currentTimestamp = CACurrentMediaTime()
4659-
if let previousSearchActivationTimestamp = self.previousSearchToggleTimestamp, currentTimestamp < previousSearchActivationTimestamp + 0.6 {
4660-
return
4661-
}
4662-
self.previousSearchToggleTimestamp = currentTimestamp
4663-
4664-
if let storyTooltip = self.storyTooltip {
4665-
storyTooltip.dismiss()
4666-
}
4667-
4668-
var filter = filter
4669-
if case .forum = self.chatListDisplayNode.effectiveContainerNode.location {
4670-
filter = .topics
4671-
}
4672-
4673-
if self.chatListDisplayNode.searchDisplayController == nil {
4674-
/*if !skipScrolling, let searchContentNode = self.searchContentNode, searchContentNode.expansionProgress != 1.0 {
4675-
self.scrollToTop?()
4676-
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.2, execute: { [weak self] in
4677-
self?.activateSearch(filter: filter, query: query, skipScrolling: true)
4678-
})
4652+
func activateSearch(filter: ChatListSearchFilter = .chats, query: String? = nil, skipScrolling: Bool = false, searchContentNode: NavigationBarSearchContentNode?) {
4653+
Task { @MainActor [weak self] in
4654+
guard let self else {
4655+
return
4656+
}
4657+
4658+
let currentTimestamp = CACurrentMediaTime()
4659+
if let previousSearchActivationTimestamp = self.previousSearchToggleTimestamp, currentTimestamp < previousSearchActivationTimestamp + 0.6 {
46794660
return
4680-
}*/
4681-
//TODO:scroll to top?
4661+
}
4662+
self.previousSearchToggleTimestamp = currentTimestamp
46824663

4683-
let _ = (combineLatest(self.chatListDisplayNode.mainContainerNode.currentItemNode.contentsReady |> take(1), self.context.account.postbox.tailChatListView(groupId: .root, count: 16, summaryComponents: ChatListEntrySummaryComponents(components: [:])) |> take(1))
4684-
|> deliverOnMainQueue).startStandalone(next: { [weak self] _, chatListView in
4685-
Task { @MainActor in
4686-
guard let strongSelf = self else {
4687-
return
4688-
}
4689-
4664+
if let storyTooltip = self.storyTooltip {
4665+
storyTooltip.dismiss()
4666+
}
4667+
4668+
var filter = filter
4669+
if case .forum = self.chatListDisplayNode.effectiveContainerNode.location {
4670+
filter = .topics
4671+
}
4672+
4673+
if self.chatListDisplayNode.searchDisplayController == nil {
4674+
let (_, _) = await combineLatest(self.chatListDisplayNode.mainContainerNode.currentItemNode.contentsReady |> take(1), self.context.account.postbox.tailChatListView(groupId: .root, count: 16, summaryComponents: ChatListEntrySummaryComponents(components: [:])) |> take(1)).get()
4675+
4676+
do {
46904677
/*if let scrollToTop = strongSelf.scrollToTop {
4691-
scrollToTop()
4692-
}*/
4678+
scrollToTop()
4679+
}*/
46934680

46944681
let tabsIsEmpty: Bool
4695-
if let (resolvedItems, displayTabsAtBottom, _) = strongSelf.tabContainerData {
4682+
if let (resolvedItems, displayTabsAtBottom, _) = self.tabContainerData {
46964683
tabsIsEmpty = resolvedItems.count <= 1 || displayTabsAtBottom
46974684
} else {
46984685
tabsIsEmpty = true
@@ -4702,40 +4689,43 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
47024689

47034690
let displaySearchFilters = true
47044691

4705-
if let filterContainerNodeAndActivate = await strongSelf.chatListDisplayNode.activateSearch(placeholderNode: searchContentNode.placeholderNode, displaySearchFilters: displaySearchFilters, hasDownloads: strongSelf.hasDownloads, initialFilter: filter, navigationController: strongSelf.navigationController as? NavigationController) {
4692+
if let filterContainerNodeAndActivate = await self.chatListDisplayNode.activateSearch(placeholderNode: searchContentNode?.placeholderNode, displaySearchFilters: displaySearchFilters, hasDownloads: self.hasDownloads, initialFilter: filter, navigationController: self.navigationController as? NavigationController, searchBarIsExternal: true) {
47064693
let (filterContainerNode, activate) = filterContainerNodeAndActivate
47074694
if displaySearchFilters {
47084695
let searchTabsNode = SparseNode()
4709-
strongSelf.searchTabsNode = searchTabsNode
4696+
self.searchTabsNode = searchTabsNode
47104697
searchTabsNode.addSubnode(filterContainerNode)
47114698
}
47124699

47134700
activate(filter != .downloads)
47144701

4715-
if let searchContentNode = strongSelf.chatListDisplayNode.searchDisplayController?.contentNode as? ChatListSearchContainerNode {
4702+
if let searchContentNode = self.chatListDisplayNode.searchDisplayController?.contentNode as? ChatListSearchContainerNode {
47164703
searchContentNode.search(filter: filter, query: query)
47174704
}
47184705
}
47194706

47204707
let transition: ContainedViewLayoutTransition = .animated(duration: 0.4, curve: .spring)
4721-
strongSelf.setDisplayNavigationBar(false, transition: transition)
4722-
4723-
(strongSelf.parent as? TabBarController)?.updateIsTabBarHidden(true, transition: .animated(duration: 0.4, curve: .spring))
4724-
}
4725-
})
4726-
4727-
self.isSearchActive = true
4728-
if let navigationController = self.navigationController as? NavigationController {
4729-
for controller in navigationController.globalOverlayControllers {
4730-
if let controller = controller as? VoiceChatOverlayController {
4731-
controller.updateVisibility()
4732-
break
4708+
self.setDisplayNavigationBar(false, transition: transition)
4709+
self.updateTabBarSearchState(ViewController.TabBarSearchState(isActive: true), transition: transition)
4710+
if let searchBarNode = self.currentTabBarSearchNode?() as? SearchBarNode {
4711+
self.chatListDisplayNode.searchDisplayController?.setSearchBar(searchBarNode)
4712+
searchBarNode.activate()
4713+
}
4714+
4715+
self.isSearchActive = true
4716+
if let navigationController = self.navigationController as? NavigationController {
4717+
for controller in navigationController.globalOverlayControllers {
4718+
if let controller = controller as? VoiceChatOverlayController {
4719+
controller.updateVisibility()
4720+
break
4721+
}
4722+
}
47334723
}
47344724
}
4735-
}
4736-
} else if self.isSearchActive {
4737-
if let searchContentNode = self.chatListDisplayNode.searchDisplayController?.contentNode as? ChatListSearchContainerNode {
4738-
searchContentNode.search(filter: filter, query: query)
4725+
} else if self.isSearchActive {
4726+
if let searchContentNode = self.chatListDisplayNode.searchDisplayController?.contentNode as? ChatListSearchContainerNode {
4727+
searchContentNode.search(filter: filter, query: query)
4728+
}
47394729
}
47404730
}
47414731
}
@@ -4766,6 +4756,8 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
47664756
}
47674757
completion = self.chatListDisplayNode.deactivateSearch(placeholderNode: searchContentNode.placeholderNode, animated: animated)
47684758
searchContentNode.placeholderNode.frame = previousFrame
4759+
} else {
4760+
completion = self.chatListDisplayNode.deactivateSearch(placeholderNode: nil, animated: animated)
47694761
}
47704762

47714763
self.chatListDisplayNode.tempAllowAvatarExpansion = true
@@ -4780,7 +4772,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
47804772

47814773
completion?()
47824774

4783-
(self.parent as? TabBarController)?.updateIsTabBarHidden(false, transition: .animated(duration: 0.4, curve: .spring))
4775+
self.updateTabBarSearchState(ViewController.TabBarSearchState(isActive: false), transition: transition)
47844776

47854777
self.isSearchActive = false
47864778
if let navigationController = self.navigationController as? NavigationController {
@@ -6236,6 +6228,14 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
62366228
strongSelf.context.sharedContext.mainWindow?.presentInGlobalOverlay(controller)
62376229
})
62386230
}
6231+
6232+
override public func tabBarActivateSearch() {
6233+
self.activateSearch()
6234+
}
6235+
6236+
override public func tabBarDeactivateSearch() {
6237+
self.deactivateSearch(animated: true)
6238+
}
62396239

62406240
private var playedSignUpCompletedAnimation = false
62416241
public func playSignUpCompletedAnimation() {

0 commit comments

Comments
 (0)