forked from Layerex/telegram-desktop-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0005-Option-to-disable-stories.patch
77 lines (70 loc) · 2.84 KB
/
0005-Option-to-disable-stories.patch
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
diff --git a/Telegram/SourceFiles/data/data_stories.cpp b/Telegram/SourceFiles/data/data_stories.cpp
index 668ec4c..7310345 100644
--- a/Telegram/SourceFiles/data/data_stories.cpp
+++ b/Telegram/SourceFiles/data/data_stories.cpp
@@ -6,6 +6,7 @@ For license and copyright information please follow this link:
#include "data/data_stories.h"
#include "api/api_report.h"
+#include "base/options.h"
#include "base/unixtime.h"
#include "apiwrap.h"
#include "core/application.h"
@@ -48,6 +49,13 @@ constexpr auto kPollingViewsPerPage = Story::kRecentViewersMax;
using UpdateFlag = StoryUpdate::Flag;
+base::options::toggle DisableStories({
+ .id = kOptionDisableStories,
+ .name = "Disable stories",
+ .description = "",
+ .defaultValue = false,
+});
+
[[nodiscard]] std::optional<StoryMedia> ParseMedia(
not_null<Session*> owner,
const MTPMessageMedia &media) {
@@ -93,12 +101,14 @@ std::vector<StoryId> RespectingPinned(const StoriesIds &ids) {
return result;
}
+const char kOptionDisableStories[] = "disable-stories";
+
StoriesSourceInfo StoriesSource::info() const {
return {
.id = peer->id,
- .last = ids.empty() ? 0 : ids.back().date,
- .count = uint32(std::min(int(ids.size()), kMaxSegmentsCount)),
- .unreadCount = uint32(std::min(unreadCount(), kMaxSegmentsCount)),
+ .last = DisableStories.value() || ids.empty() ? 0 : ids.back().date,
+ .count = !DisableStories.value() * uint32(std::min(int(ids.size()), kMaxSegmentsCount)),
+ .unreadCount = !DisableStories.value() * uint32(std::min(unreadCount(), kMaxSegmentsCount)),
.premium = (peer->isUser() && peer->asUser()->isPremium()) ? 1U : 0,
};
}
diff --git a/Telegram/SourceFiles/data/data_stories.h b/Telegram/SourceFiles/data/data_stories.h
index 2a172e4..679b3ad 100644
--- a/Telegram/SourceFiles/data/data_stories.h
+++ b/Telegram/SourceFiles/data/data_stories.h
@@ -31,6 +31,8 @@ struct StoryIdDates;
class Story;
class StoryPreload;
+extern const char kOptionDisableStories[];
+
struct StoriesIds {
base::flat_set<StoryId, std::greater<>> list;
std::vector<StoryId> pinnedToTop;
diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp b/Telegram/SourceFiles/settings/settings_experimental.cpp
index f578bce..92f0fff 100644
--- a/Telegram/SourceFiles/settings/settings_experimental.cpp
+++ b/Telegram/SourceFiles/settings/settings_experimental.cpp
@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "settings/settings_experimental.h"
+#include "data/data_stories.h"
#include "ui/boxes/confirm_box.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/wrap/slide_wrap.h"
@@ -140,6 +141,7 @@ void SetupExperimental(
: rpl::producer<>()));
};
+ addToggle(Data::kOptionDisableStories);
addToggle(ChatHelpers::kOptionTabbedPanelShowOnClick);
addToggle(Dialogs::kOptionForumHideChatsList);
addToggle(Core::kOptionFractionalScalingEnabled);