summarylogtreecommitdiffstats
path: root/search_by_any_user.patch
blob: e50f9524d4c306b80d0c6b6a345ac0a347330eff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
Author: TheWug (https://github.com/TheWug)
Description: Allows searching by any user instead of only members of a chat

diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp
index dfea07f62..e2e332577 100644
--- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp
+++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp
@@ -299,7 +299,7 @@ void AddSpecialBoxController::migrate(not_null<ChannelData*> channel) {
 
 std::unique_ptr<PeerListRow> AddSpecialBoxController::createSearchRow(
 		not_null<PeerData*> peer) {
-	if (peer->isSelf()) {
+	if (_excludeSelf && peer->isSelf()) {
 		return nullptr;
 	}
 	if (const auto user = peer->asUser()) {
@@ -312,6 +312,8 @@ void AddSpecialBoxController::prepare() {
 	delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled);
 	auto title = [&] {
 		switch (_role) {
+		case Role::Members:
+			return tr::lng_profile_participants_section();
 		case Role::Admins:
 			return tr::lng_channel_add_admin();
 		case Role::Restricted:
@@ -799,7 +801,8 @@ void AddSpecialBoxController::kickUser(
 }
 
 bool AddSpecialBoxController::appendRow(not_null<UserData*> user) {
-	if (delegate()->peerListFindRow(user->id) || user->isSelf()) {
+	if (delegate()->peerListFindRow(user->id)
+		|| (_excludeSelf && user->isSelf())) {
 		return false;
 	}
 	delegate()->peerListAppendRow(createRow(user));
diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.h b/Telegram/SourceFiles/boxes/peers/add_participants_box.h
index deef59d01..b1fab5a43 100644
--- a/Telegram/SourceFiles/boxes/peers/add_participants_box.h
+++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.h
@@ -131,6 +131,9 @@ private:
 	AdminDoneCallback _adminDoneCallback;
 	BannedDoneCallback _bannedDoneCallback;
 
+protected:
+	bool _excludeSelf = true;
+
 };
 
 // Finds chat/channel members, then contacts, then global search results.
diff --git a/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp b/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp
index b5823b308..9e11fa53e 100644
--- a/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp
+++ b/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp
@@ -19,18 +19,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 namespace Dialogs {
 
 void ShowSearchFromBox(
-		not_null<Window::SessionNavigation*> navigation,
 		not_null<PeerData*> peer,
 		Fn<void(not_null<UserData*>)> callback,
 		Fn<void()> closedCallback) {
 	auto createController = [
-		navigation,
 		peer,
 		callback = std::move(callback)
 	]() -> std::unique_ptr<PeerListController> {
 		if (peer && (peer->isChat() || peer->isMegagroup())) {
 			return std::make_unique<Dialogs::SearchFromController>(
-				navigation,
 				peer,
 				std::move(callback));
 		}
@@ -50,18 +47,20 @@ void ShowSearchFromBox(
 }
 
 SearchFromController::SearchFromController(
-	not_null<Window::SessionNavigation*> navigation,
 	not_null<PeerData*> peer,
 	Fn<void(not_null<UserData*>)> callback)
-: ParticipantsBoxController(
-	navigation,
+: AddSpecialBoxController(
 	peer,
-	ParticipantsBoxController::Role::Members)
-, _callback(std::move(callback)) {
+	ParticipantsBoxController::Role::Members,
+	AdminDoneCallback(),
+	BannedDoneCallback())
+, _callback(std::move(callback))
+{
+	_excludeSelf = false;
 }
 
 void SearchFromController::prepare() {
-	ParticipantsBoxController::prepare();
+	AddSpecialBoxController::prepare();
 	delegate()->peerListSetTitle(tr::lng_search_messages_from());
 }
 
diff --git a/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.h b/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.h
index 3a45b7b5c..709353bb5 100644
--- a/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.h
+++ b/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.h
@@ -8,20 +8,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 #pragma once
 
 #include "boxes/peer_list_box.h"
-#include "boxes/peers/edit_participants_box.h"
+#include "boxes/peers/add_participants_box.h"
 
 namespace Dialogs {
 
 void ShowSearchFromBox(
-	not_null<Window::SessionNavigation*> navigation,
 	not_null<PeerData*> peer,
 	Fn<void(not_null<UserData*>)> callback,
 	Fn<void()> closedCallback);
 
-class SearchFromController : public ParticipantsBoxController {
+class SearchFromController : public AddSpecialBoxController {
 public:
 	SearchFromController(
-		not_null<Window::SessionNavigation*> navigation,
 		not_null<PeerData*> peer,
 		Fn<void(not_null<UserData*>)> callback);
 
@@ -29,7 +27,7 @@ public:
 	void rowClicked(not_null<PeerListRow*> row) override;
 
 protected:
-	std::unique_ptr<PeerListRow> createRow(not_null<UserData*> user) const override;
+	std::unique_ptr<PeerListRow> createRow(not_null<UserData*> user) const;
 
 private:
 	Fn<void(not_null<UserData*>)> _callback;
diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp
index 68797353e..888b2dc4d 100644
--- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp
+++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp
@@ -1322,7 +1322,6 @@ void Widget::showSearchFrom() {
 	if (const auto peer = _searchInChat.peer()) {
 		const auto chat = _searchInChat;
 		ShowSearchFromBox(
-			controller(),
 			peer,
 			crl::guard(this, [=](not_null<UserData*> user) {
 				Ui::hideLayer();