Skip to content

Commit b7a73c0

Browse files
committed
Update to 5.3.2
1 parent 98f3a04 commit b7a73c0

File tree

4 files changed

+166
-75
lines changed

4 files changed

+166
-75
lines changed

0002-Disable-saving-restrictions.patch

Lines changed: 125 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp
2-
index e3bbba7..5bc409d 100644
2+
index 915b12f..78c88e8 100644
33
--- a/Telegram/SourceFiles/core/click_handler_types.cpp
44
+++ b/Telegram/SourceFiles/core/click_handler_types.cpp
5-
@@ -333,9 +333,7 @@ void MonospaceClickHandler::onClick(ClickContext context) const {
5+
@@ -366,15 +366,6 @@ void MonospaceClickHandler::onClick(ClickContext context) const {
66
if (const auto controller = my.sessionWindow.get()) {
77
auto &data = controller->session().data();
88
const auto item = data.message(my.itemId);
99
- const auto hasCopyRestriction = item
1010
- && (!item->history()->peer->allowsForwarding()
1111
- || item->forbidsForward());
12-
+ const auto hasCopyRestriction = false;
13-
if (hasCopyRestriction) {
14-
controller->showToast(item->history()->peer->isBroadcast()
15-
? tr::lng_error_nocopy_channel(tr::now)
12+
- if (hasCopyRestriction) {
13+
- controller->showToast(item->history()->peer->isBroadcast()
14+
- ? tr::lng_error_nocopy_channel(tr::now)
15+
- : tr::lng_error_nocopy_group(tr::now));
16+
- return;
17+
- }
18+
controller->showToast(tr::lng_text_copied(tr::now));
19+
}
20+
TextUtilities::SetClipboardText(TextForMimeData::Simple(_text.trimmed()));
1621
diff --git a/Telegram/SourceFiles/data/data_story.cpp b/Telegram/SourceFiles/data/data_story.cpp
17-
index d5faa43..c6b26dc 100644
22+
index 38ea28a..53ccc5a 100644
1823
--- a/Telegram/SourceFiles/data/data_story.cpp
1924
+++ b/Telegram/SourceFiles/data/data_story.cpp
20-
@@ -318,12 +318,11 @@ bool Story::edited() const {
25+
@@ -458,12 +458,11 @@ bool Story::out() const {
2126
}
2227

2328
bool Story::canDownloadIfPremium() const {
@@ -33,10 +38,10 @@ index d5faa43..c6b26dc 100644
3338

3439
bool Story::canShare() const {
3540
diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp
36-
index 2f1dabe..bd6d25f 100644
41+
index 7838dda..cd77292 100644
3742
--- a/Telegram/SourceFiles/history/history_inner_widget.cpp
3843
+++ b/Telegram/SourceFiles/history/history_inner_widget.cpp
39-
@@ -649,14 +649,7 @@ void HistoryInner::setupSharingDisallowed() {
44+
@@ -558,14 +558,7 @@ void HistoryInner::setupSharingDisallowed() {
4045
}
4146

4247
bool HistoryInner::hasSelectRestriction() const {
@@ -52,7 +57,7 @@ index 2f1dabe..bd6d25f 100644
5257
}
5358

5459
void HistoryInner::messagesReceived(
55-
@@ -2665,12 +2658,12 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
60+
@@ -2847,52 +2840,27 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
5661
}
5762

5863
bool HistoryInner::hasCopyRestriction(HistoryItem *item) const {
@@ -67,27 +72,69 @@ index 2f1dabe..bd6d25f 100644
6772
}
6873

6974
bool HistoryInner::showCopyRestriction(HistoryItem *item) {
75+
- if (!hasCopyRestriction(item)) {
76+
- return false;
77+
- }
78+
- _controller->showToast(_peer->isBroadcast()
79+
- ? tr::lng_error_nocopy_channel(tr::now)
80+
- : tr::lng_error_nocopy_group(tr::now));
81+
- return true;
82+
+ return false;
83+
}
84+
85+
bool HistoryInner::showCopyMediaRestriction(not_null<HistoryItem*> item) {
86+
- if (!hasCopyMediaRestriction(item)) {
87+
- return false;
88+
- }
89+
- _controller->showToast(_peer->isBroadcast()
90+
- ? tr::lng_error_nocopy_channel(tr::now)
91+
- : tr::lng_error_nocopy_group(tr::now));
92+
- return true;
93+
+ return false;
94+
}
95+
96+
bool HistoryInner::hasCopyRestrictionForSelected() const {
97+
- if (hasCopyRestriction()) {
98+
- return true;
99+
- }
100+
- for (const auto &[item, selection] : _selected) {
101+
- if (item && item->forbidsForward()) {
102+
- return true;
103+
- }
104+
- }
105+
return false;
106+
}
107+
108+
bool HistoryInner::showCopyRestrictionForSelected() {
109+
- for (const auto &[item, selection] : _selected) {
110+
- if (showCopyRestriction(item)) {
111+
- return true;
112+
- }
113+
- }
114+
return false;
115+
}
116+
70117
diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp
71-
index 55e1def..745338c 100644
118+
index d2386e7..5f61381 100644
72119
--- a/Telegram/SourceFiles/history/history_item.cpp
73120
+++ b/Telegram/SourceFiles/history/history_item.cpp
74-
@@ -1999,11 +1999,6 @@ bool HistoryItem::forbidsForward() const {
121+
@@ -2244,11 +2244,6 @@ bool HistoryItem::forbidsForward() const {
75122
}
76123

77124
bool HistoryItem::forbidsSaving() const {
78125
- if (forbidsForward()) {
79126
- return true;
80127
- } else if (const auto invoice = _media ? _media->invoice() : nullptr) {
81-
- return (invoice->extendedMedia != nullptr);
128+
- return HasExtendedMedia(*invoice);
82129
- }
83130
return false;
84131
}
85132

86133
diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
87-
index 3de0cb2..0359ab3 100644
134+
index 4155adf..5ea96fa 100644
88135
--- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
89136
+++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
90-
@@ -1420,13 +1420,11 @@ bool ListWidget::isEmpty() const {
137+
@@ -1515,73 +1515,31 @@ bool ListWidget::isEmpty() const {
91138
}
92139

93140
bool ListWidget::hasCopyRestriction(HistoryItem *item) const {
@@ -103,7 +150,27 @@ index 3de0cb2..0359ab3 100644
103150
}
104151

105152
bool ListWidget::showCopyRestriction(HistoryItem *item) {
106-
@@ -1452,21 +1450,6 @@ bool ListWidget::showCopyMediaRestriction(not_null<HistoryItem*> item) {
153+
- const auto type = _delegate->listCopyRestrictionType(item);
154+
- if (type == CopyRestrictionType::None) {
155+
- return false;
156+
- }
157+
- _delegate->listUiShow()->showToast((type == CopyRestrictionType::Channel)
158+
- ? tr::lng_error_nocopy_channel(tr::now)
159+
- : tr::lng_error_nocopy_group(tr::now));
160+
- return true;
161+
+ return false;
162+
}
163+
164+
bool ListWidget::showCopyMediaRestriction(not_null<HistoryItem*> item) {
165+
- const auto type = _delegate->listCopyMediaRestrictionType(item);
166+
- if (type == CopyRestrictionType::None) {
167+
- return false;
168+
- }
169+
- _delegate->listUiShow()->showToast((type == CopyRestrictionType::Channel)
170+
- ? tr::lng_error_nocopy_channel(tr::now)
171+
- : tr::lng_error_nocopy_group(tr::now));
172+
- return true;
173+
+ return false;
107174
}
108175

109176
bool ListWidget::hasCopyRestrictionForSelected() const {
@@ -125,7 +192,18 @@ index 3de0cb2..0359ab3 100644
125192
return false;
126193
}
127194

128-
@@ -1485,8 +1468,7 @@ bool ListWidget::showCopyRestrictionForSelected() {
195+
bool ListWidget::showCopyRestrictionForSelected() {
196+
- if (_selected.empty()) {
197+
- if (_selectedTextItem && showCopyRestriction(_selectedTextItem)) {
198+
- return true;
199+
- }
200+
- }
201+
- for (const auto &[itemId, selection] : _selected) {
202+
- if (showCopyRestriction(session().data().message(itemId))) {
203+
- return true;
204+
- }
205+
- }
206+
return false;
129207
}
130208

131209
bool ListWidget::hasSelectRestriction() const {
@@ -134,34 +212,37 @@ index 3de0cb2..0359ab3 100644
134212
+ return false;
135213
}
136214

137-
auto ListWidget::findViewForPinnedTracking(int top) const
215+
Element *ListWidget::lookupItemByY(int y) const {
138216
diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
139-
index fa0d6ed..a569215 100644
217+
index 92bd218..57c5150 100644
140218
--- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
141219
+++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
142-
@@ -1153,15 +1153,14 @@ void TopBarWidget::updateMembersShowArea() {
220+
@@ -1240,15 +1240,14 @@ void TopBarWidget::updateMembersShowArea() {
143221
}
144222

145223
bool TopBarWidget::showSelectedState() const {
146224
- return (_selectedCount > 0)
147225
- && (_canDelete || _canForward || _canSendNow);
148-
+ return _selectedCount > 0;
226+
+ return (_selectedCount > 0);
149227
}
150228

151229
void TopBarWidget::showSelected(SelectedState state) {
152-
auto canDelete = (state.count > 0 && state.count == state.canDeleteCount);
153-
auto canForward = (state.count > 0 && state.count == state.canForwardCount);
154-
auto canSendNow = (state.count > 0 && state.count == state.canSendNowCount);
230+
- auto canDelete = (state.count > 0 && state.count == state.canDeleteCount);
231+
- auto canForward = (state.count > 0 && state.count == state.canForwardCount);
232+
- auto canSendNow = (state.count > 0 && state.count == state.canSendNowCount);
155233
- auto count = (!canDelete && !canForward && !canSendNow) ? 0 : state.count;
234+
+ auto canDelete = (state.count > 0);
235+
+ auto canForward = (state.count > 0);
236+
+ auto canSendNow = (state.count > 0);
156237
+ auto count = state.count;
157238
if (_selectedCount == count
158239
&& _canDelete == canDelete
159240
&& _canForward == canForward
160241
diff --git a/Telegram/SourceFiles/info/media/info_media_provider.cpp b/Telegram/SourceFiles/info/media/info_media_provider.cpp
161-
index 3e75975..ee23733 100644
242+
index 2fc6973..e3101f3 100644
162243
--- a/Telegram/SourceFiles/info/media/info_media_provider.cpp
163244
+++ b/Telegram/SourceFiles/info/media/info_media_provider.cpp
164-
@@ -87,14 +87,7 @@ Type Provider::type() {
245+
@@ -88,13 +88,6 @@ Type Provider::type() {
165246
}
166247

167248
bool Provider::hasSelectRestriction() {
@@ -172,16 +253,14 @@ index 3e75975..ee23733 100644
172253
- } else if (const auto channel = _peer->asChannel()) {
173254
- return !channel->canDeleteMessages();
174255
- }
175-
- return true;
176-
+ return false;
256+
return true;
177257
}
178258

179-
rpl::producer<bool> Provider::hasSelectRestrictionChanges() {
180259
diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
181-
index 0a58cdb..626773f 100644
260+
index c6a7e9c..8407567 100644
182261
--- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
183262
+++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
184-
@@ -1031,13 +1031,7 @@ QSize OverlayWidget::flipSizeByRotation(QSize size) const {
263+
@@ -1033,26 +1033,11 @@ QSize OverlayWidget::flipSizeByRotation(QSize size) const {
185264
}
186265

187266
bool OverlayWidget::hasCopyMediaRestriction(bool skipPremiumCheck) const {
@@ -196,3 +275,17 @@ index 0a58cdb..626773f 100644
196275
}
197276

198277
bool OverlayWidget::showCopyMediaRestriction(bool skipPRemiumCheck) {
278+
- if (!hasCopyMediaRestriction(skipPRemiumCheck)) {
279+
- return false;
280+
- } else if (_stories) {
281+
- uiShow()->showToast(tr::lng_error_nocopy_story(tr::now));
282+
- } else if (_history) {
283+
- uiShow()->showToast(_history->peer->isBroadcast()
284+
- ? tr::lng_error_nocopy_channel(tr::now)
285+
- : tr::lng_error_nocopy_group(tr::now));
286+
- }
287+
- return true;
288+
+ return false;
289+
}
290+
291+
bool OverlayWidget::videoShown() const {

0005-Option-to-disable-stories.patch

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
diff --git a/Telegram/SourceFiles/data/data_stories.cpp b/Telegram/SourceFiles/data/data_stories.cpp
2-
index d3baee3..04ee5a4 100644
2+
index 668ec4c..7310345 100644
33
--- a/Telegram/SourceFiles/data/data_stories.cpp
44
+++ b/Telegram/SourceFiles/data/data_stories.cpp
5-
@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
5+
@@ -6,6 +6,7 @@ For license and copyright information please follow this link:
66
#include "data/data_stories.h"
77

88
#include "api/api_report.h"
99
+#include "base/options.h"
1010
#include "base/unixtime.h"
1111
#include "apiwrap.h"
1212
#include "core/application.h"
13-
@@ -47,6 +48,14 @@ constexpr auto kPollingViewsPerPage = Story::kRecentViewersMax;
13+
@@ -48,6 +49,13 @@ constexpr auto kPollingViewsPerPage = Story::kRecentViewersMax;
1414

1515
using UpdateFlag = StoryUpdate::Flag;
1616

@@ -20,34 +20,30 @@ index d3baee3..04ee5a4 100644
2020
+ .description = "",
2121
+ .defaultValue = false,
2222
+});
23-
+
2423
+
2524
[[nodiscard]] std::optional<StoryMedia> ParseMedia(
2625
not_null<Session*> owner,
2726
const MTPMessageMedia &media) {
28-
@@ -77,6 +86,8 @@ using UpdateFlag = StoryUpdate::Flag;
29-
30-
} // namespace
27+
@@ -93,12 +101,14 @@ std::vector<StoryId> RespectingPinned(const StoriesIds &ids) {
28+
return result;
29+
}
3130

3231
+const char kOptionDisableStories[] = "disable-stories";
3332
+
3433
StoriesSourceInfo StoriesSource::info() const {
3534
return {
3635
.id = peer->id,
37-
@@ -426,6 +437,11 @@ Story *Stories::parseAndApply(
38-
not_null<PeerData*> peer,
39-
const MTPDstoryItem &data,
40-
TimeId now) {
41-
+
42-
+ if (DisableStories.value()) {
43-
+ return nullptr;
44-
+ }
45-
+
46-
const auto media = ParseMedia(_owner, data.vmedia());
47-
if (!media) {
48-
return nullptr;
36+
- .last = ids.empty() ? 0 : ids.back().date,
37+
- .count = uint32(std::min(int(ids.size()), kMaxSegmentsCount)),
38+
- .unreadCount = uint32(std::min(unreadCount(), kMaxSegmentsCount)),
39+
+ .last = DisableStories.value() || ids.empty() ? 0 : ids.back().date,
40+
+ .count = !DisableStories.value() * uint32(std::min(int(ids.size()), kMaxSegmentsCount)),
41+
+ .unreadCount = !DisableStories.value() * uint32(std::min(unreadCount(), kMaxSegmentsCount)),
42+
.premium = (peer->isUser() && peer->asUser()->isPremium()) ? 1U : 0,
43+
};
44+
}
4945
diff --git a/Telegram/SourceFiles/data/data_stories.h b/Telegram/SourceFiles/data/data_stories.h
50-
index 1cc3bb3..b42ef79 100644
46+
index 2a172e4..679b3ad 100644
5147
--- a/Telegram/SourceFiles/data/data_stories.h
5248
+++ b/Telegram/SourceFiles/data/data_stories.h
5349
@@ -31,6 +31,8 @@ struct StoryIdDates;
@@ -58,20 +54,20 @@ index 1cc3bb3..b42ef79 100644
5854
+
5955
struct StoriesIds {
6056
base::flat_set<StoryId, std::greater<>> list;
61-
57+
std::vector<StoryId> pinnedToTop;
6258
diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp b/Telegram/SourceFiles/settings/settings_experimental.cpp
63-
index 3b9a5a0..2f9ad4d 100644
59+
index f578bce..92f0fff 100644
6460
--- a/Telegram/SourceFiles/settings/settings_experimental.cpp
6561
+++ b/Telegram/SourceFiles/settings/settings_experimental.cpp
66-
@@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
67-
#include "core/sandbox.h"
68-
#include "core/launcher.h"
69-
#include "chat_helpers/tabbed_panel.h"
70-
+#include "data/data_stories.h";
71-
#include "dialogs/dialogs_widget.h"
72-
#include "info/profile/info_profile_actions.h"
73-
#include "lang/lang_keys.h"
74-
@@ -141,5 +142,6 @@ void SetupExperimental(
62+
@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
63+
*/
64+
#include "settings/settings_experimental.h"
65+
66+
+#include "data/data_stories.h"
67+
#include "ui/boxes/confirm_box.h"
68+
#include "ui/wrap/vertical_layout.h"
69+
#include "ui/wrap/slide_wrap.h"
70+
@@ -140,6 +141,7 @@ void SetupExperimental(
7571
: rpl::producer<>()));
7672
};
7773

0 commit comments

Comments
 (0)