mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
feat: add hide "All chats" folder (thx 64Gram)
This commit is contained in:
parent
70e49025b1
commit
2ef9724fa2
6 changed files with 58 additions and 4 deletions
|
@ -3980,6 +3980,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ayu_CustomizationHeader" = "Customization";
|
||||
"ayu_DeletedMarkText" = "Deleted mark";
|
||||
"ayu_EditedMarkText" = "Edited mark";
|
||||
"ayu_HideAllChats" = "Hide \"All chats\" folder";
|
||||
"ayu_ShowGhostToggleInDrawer" = "Show ghost mode toggle";
|
||||
"ayu_ShowKllButtonInDrawer" = "Show kill app button";
|
||||
"ayu_SettingsShowID" = "Show peer ID";
|
||||
|
|
|
@ -248,6 +248,11 @@ namespace AyuSettings
|
|||
{
|
||||
showMessageSeconds = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_hideAllChatsFolder(bool val)
|
||||
{
|
||||
hideAllChatsFolder = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_stickerConfirmation(bool val)
|
||||
{
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace AyuSettings
|
|||
*/
|
||||
showPeerId = 2;
|
||||
|
||||
hideAllChatsFolder = false;
|
||||
showMessageSeconds = false;
|
||||
|
||||
// ~ Confirmations
|
||||
|
@ -76,6 +77,7 @@ namespace AyuSettings
|
|||
int recentStickersCount;
|
||||
bool showGhostToggleInDrawer;
|
||||
int showPeerId;
|
||||
bool hideAllChatsFolder;
|
||||
bool showMessageSeconds;
|
||||
bool stickerConfirmation;
|
||||
bool gifConfirmation;
|
||||
|
@ -120,6 +122,8 @@ namespace AyuSettings
|
|||
|
||||
void set_showMessageSeconds(bool val);
|
||||
|
||||
void set_hideAllChatsFolder(bool val);
|
||||
|
||||
void set_stickerConfirmation(bool val);
|
||||
|
||||
void set_gifConfirmation(bool val);
|
||||
|
@ -147,6 +151,7 @@ namespace AyuSettings
|
|||
showGhostToggleInDrawer,
|
||||
showPeerId,
|
||||
showMessageSeconds,
|
||||
hideAllChatsFolder,
|
||||
stickerConfirmation,
|
||||
gifConfirmation,
|
||||
voiceConfirmation
|
||||
|
|
|
@ -296,6 +296,22 @@ namespace Settings
|
|||
|
||||
SetupShowPeerId(container, controller);
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
tr::ayu_HideAllChats(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
rpl::single(settings->hideAllChatsFolder)
|
||||
)->toggledValue(
|
||||
) | rpl::filter([=](bool enabled)
|
||||
{
|
||||
return (enabled != settings->hideAllChatsFolder);
|
||||
}) | start_with_next([=](bool enabled)
|
||||
{
|
||||
settings->set_hideAllChatsFolder(enabled);
|
||||
AyuSettings::save();
|
||||
}, container->lifetime());
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
tr::ayu_ShowGhostToggleInDrawer(),
|
||||
|
|
|
@ -25,6 +25,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "main/main_app_config.h"
|
||||
#include "apiwrap.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
|
||||
|
||||
namespace Data {
|
||||
namespace {
|
||||
|
||||
|
@ -389,10 +393,16 @@ void ChatFilters::load(bool force) {
|
|||
}
|
||||
|
||||
void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
|
||||
// AyuGram hideAllChatsFolder
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
|
||||
auto position = 0;
|
||||
auto changed = false;
|
||||
for (const auto &filter : list) {
|
||||
auto parsed = ChatFilter::FromTL(filter, _owner);
|
||||
if (settings->hideAllChatsFolder && parsed.id() == 0 && list.size() > 1) {
|
||||
continue;
|
||||
}
|
||||
const auto b = begin(_list) + position, e = end(_list);
|
||||
const auto i = ranges::find(b, e, parsed.id(), &ChatFilter::id);
|
||||
if (i == e) {
|
||||
|
@ -413,7 +423,7 @@ void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
|
|||
applyRemove(position);
|
||||
changed = true;
|
||||
}
|
||||
if (!ranges::contains(begin(_list), end(_list), 0, &ChatFilter::id)) {
|
||||
if (!settings->hideAllChatsFolder && !ranges::contains(begin(_list), end(_list), 0, &ChatFilter::id)) {
|
||||
_list.insert(begin(_list), ChatFilter());
|
||||
}
|
||||
if (changed || !_loaded || _reloading) {
|
||||
|
@ -424,9 +434,16 @@ void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
|
|||
}
|
||||
|
||||
void ChatFilters::apply(const MTPUpdate &update) {
|
||||
// AyuGram hideAllChatsFolder
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
|
||||
update.match([&](const MTPDupdateDialogFilter &data) {
|
||||
if (const auto filter = data.vfilter()) {
|
||||
set(ChatFilter::FromTL(*filter, _owner));
|
||||
auto parsed = ChatFilter::FromTL(*filter, _owner);
|
||||
if (settings->hideAllChatsFolder && parsed.id() == 0) {
|
||||
return;
|
||||
}
|
||||
set(parsed);
|
||||
} else {
|
||||
remove(data.vid().v);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_layers.h" // attentionBoxButton
|
||||
#include "styles/style_menu_icons.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
|
||||
|
||||
namespace Window {
|
||||
namespace {
|
||||
|
||||
|
@ -197,6 +201,9 @@ void FiltersMenu::scrollToButton(not_null<Ui::RpWidget*> widget) {
|
|||
}
|
||||
|
||||
void FiltersMenu::refresh() {
|
||||
// AyuGram hideAllChatsFolder
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
|
||||
const auto filters = &_session->session().data().chatsFilters();
|
||||
if (!filters->has() || _ignoreRefresh) {
|
||||
return;
|
||||
|
@ -212,7 +219,7 @@ void FiltersMenu::refresh() {
|
|||
const auto maxLimit = (reorderAll ? 1 : 0)
|
||||
+ Data::PremiumLimits(&_session->session()).dialogFiltersCurrent();
|
||||
const auto premiumFrom = (reorderAll ? 0 : 1) + maxLimit;
|
||||
if (!reorderAll) {
|
||||
if (!reorderAll && !settings->hideAllChatsFolder) {
|
||||
_reorder->addPinnedInterval(0, 1);
|
||||
}
|
||||
_reorder->addPinnedInterval(
|
||||
|
@ -542,9 +549,12 @@ void FiltersMenu::applyReorder(
|
|||
return;
|
||||
}
|
||||
|
||||
// AyuGram hideAllChatsFolder
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
|
||||
const auto filters = &_session->session().data().chatsFilters();
|
||||
const auto &list = filters->list();
|
||||
if (!premium()) {
|
||||
if (!settings->hideAllChatsFolder && !premium()) {
|
||||
if (list[0].id() != FilterId()) {
|
||||
filters->moveAllToFront();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue