mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +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_CustomizationHeader" = "Customization";
|
||||||
"ayu_DeletedMarkText" = "Deleted mark";
|
"ayu_DeletedMarkText" = "Deleted mark";
|
||||||
"ayu_EditedMarkText" = "Edited mark";
|
"ayu_EditedMarkText" = "Edited mark";
|
||||||
|
"ayu_HideAllChats" = "Hide \"All chats\" folder";
|
||||||
"ayu_ShowGhostToggleInDrawer" = "Show ghost mode toggle";
|
"ayu_ShowGhostToggleInDrawer" = "Show ghost mode toggle";
|
||||||
"ayu_ShowKllButtonInDrawer" = "Show kill app button";
|
"ayu_ShowKllButtonInDrawer" = "Show kill app button";
|
||||||
"ayu_SettingsShowID" = "Show peer ID";
|
"ayu_SettingsShowID" = "Show peer ID";
|
||||||
|
|
|
@ -249,6 +249,11 @@ namespace AyuSettings
|
||||||
showMessageSeconds = val;
|
showMessageSeconds = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AyuGramSettings::set_hideAllChatsFolder(bool val)
|
||||||
|
{
|
||||||
|
hideAllChatsFolder = val;
|
||||||
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_stickerConfirmation(bool val)
|
void AyuGramSettings::set_stickerConfirmation(bool val)
|
||||||
{
|
{
|
||||||
stickerConfirmation = val;
|
stickerConfirmation = val;
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace AyuSettings
|
||||||
*/
|
*/
|
||||||
showPeerId = 2;
|
showPeerId = 2;
|
||||||
|
|
||||||
|
hideAllChatsFolder = false;
|
||||||
showMessageSeconds = false;
|
showMessageSeconds = false;
|
||||||
|
|
||||||
// ~ Confirmations
|
// ~ Confirmations
|
||||||
|
@ -76,6 +77,7 @@ namespace AyuSettings
|
||||||
int recentStickersCount;
|
int recentStickersCount;
|
||||||
bool showGhostToggleInDrawer;
|
bool showGhostToggleInDrawer;
|
||||||
int showPeerId;
|
int showPeerId;
|
||||||
|
bool hideAllChatsFolder;
|
||||||
bool showMessageSeconds;
|
bool showMessageSeconds;
|
||||||
bool stickerConfirmation;
|
bool stickerConfirmation;
|
||||||
bool gifConfirmation;
|
bool gifConfirmation;
|
||||||
|
@ -120,6 +122,8 @@ namespace AyuSettings
|
||||||
|
|
||||||
void set_showMessageSeconds(bool val);
|
void set_showMessageSeconds(bool val);
|
||||||
|
|
||||||
|
void set_hideAllChatsFolder(bool val);
|
||||||
|
|
||||||
void set_stickerConfirmation(bool val);
|
void set_stickerConfirmation(bool val);
|
||||||
|
|
||||||
void set_gifConfirmation(bool val);
|
void set_gifConfirmation(bool val);
|
||||||
|
@ -147,6 +151,7 @@ namespace AyuSettings
|
||||||
showGhostToggleInDrawer,
|
showGhostToggleInDrawer,
|
||||||
showPeerId,
|
showPeerId,
|
||||||
showMessageSeconds,
|
showMessageSeconds,
|
||||||
|
hideAllChatsFolder,
|
||||||
stickerConfirmation,
|
stickerConfirmation,
|
||||||
gifConfirmation,
|
gifConfirmation,
|
||||||
voiceConfirmation
|
voiceConfirmation
|
||||||
|
|
|
@ -296,6 +296,22 @@ namespace Settings
|
||||||
|
|
||||||
SetupShowPeerId(container, controller);
|
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(
|
AddButton(
|
||||||
container,
|
container,
|
||||||
tr::ayu_ShowGhostToggleInDrawer(),
|
tr::ayu_ShowGhostToggleInDrawer(),
|
||||||
|
|
|
@ -25,6 +25,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_app_config.h"
|
#include "main/main_app_config.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
|
||||||
|
// AyuGram includes
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -389,10 +393,16 @@ void ChatFilters::load(bool force) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
|
void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
|
||||||
|
// AyuGram hideAllChatsFolder
|
||||||
|
const auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
auto position = 0;
|
auto position = 0;
|
||||||
auto changed = false;
|
auto changed = false;
|
||||||
for (const auto &filter : list) {
|
for (const auto &filter : list) {
|
||||||
auto parsed = ChatFilter::FromTL(filter, _owner);
|
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 b = begin(_list) + position, e = end(_list);
|
||||||
const auto i = ranges::find(b, e, parsed.id(), &ChatFilter::id);
|
const auto i = ranges::find(b, e, parsed.id(), &ChatFilter::id);
|
||||||
if (i == e) {
|
if (i == e) {
|
||||||
|
@ -413,7 +423,7 @@ void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
|
||||||
applyRemove(position);
|
applyRemove(position);
|
||||||
changed = true;
|
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());
|
_list.insert(begin(_list), ChatFilter());
|
||||||
}
|
}
|
||||||
if (changed || !_loaded || _reloading) {
|
if (changed || !_loaded || _reloading) {
|
||||||
|
@ -424,9 +434,16 @@ void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatFilters::apply(const MTPUpdate &update) {
|
void ChatFilters::apply(const MTPUpdate &update) {
|
||||||
|
// AyuGram hideAllChatsFolder
|
||||||
|
const auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
update.match([&](const MTPDupdateDialogFilter &data) {
|
update.match([&](const MTPDupdateDialogFilter &data) {
|
||||||
if (const auto filter = data.vfilter()) {
|
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 {
|
} else {
|
||||||
remove(data.vid().v);
|
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_layers.h" // attentionBoxButton
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
|
|
||||||
|
// AyuGram includes
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -197,6 +201,9 @@ void FiltersMenu::scrollToButton(not_null<Ui::RpWidget*> widget) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FiltersMenu::refresh() {
|
void FiltersMenu::refresh() {
|
||||||
|
// AyuGram hideAllChatsFolder
|
||||||
|
const auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
const auto filters = &_session->session().data().chatsFilters();
|
const auto filters = &_session->session().data().chatsFilters();
|
||||||
if (!filters->has() || _ignoreRefresh) {
|
if (!filters->has() || _ignoreRefresh) {
|
||||||
return;
|
return;
|
||||||
|
@ -212,7 +219,7 @@ void FiltersMenu::refresh() {
|
||||||
const auto maxLimit = (reorderAll ? 1 : 0)
|
const auto maxLimit = (reorderAll ? 1 : 0)
|
||||||
+ Data::PremiumLimits(&_session->session()).dialogFiltersCurrent();
|
+ Data::PremiumLimits(&_session->session()).dialogFiltersCurrent();
|
||||||
const auto premiumFrom = (reorderAll ? 0 : 1) + maxLimit;
|
const auto premiumFrom = (reorderAll ? 0 : 1) + maxLimit;
|
||||||
if (!reorderAll) {
|
if (!reorderAll && !settings->hideAllChatsFolder) {
|
||||||
_reorder->addPinnedInterval(0, 1);
|
_reorder->addPinnedInterval(0, 1);
|
||||||
}
|
}
|
||||||
_reorder->addPinnedInterval(
|
_reorder->addPinnedInterval(
|
||||||
|
@ -542,9 +549,12 @@ void FiltersMenu::applyReorder(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AyuGram hideAllChatsFolder
|
||||||
|
const auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
const auto filters = &_session->session().data().chatsFilters();
|
const auto filters = &_session->session().data().chatsFilters();
|
||||||
const auto &list = filters->list();
|
const auto &list = filters->list();
|
||||||
if (!premium()) {
|
if (!settings->hideAllChatsFolder && !premium()) {
|
||||||
if (list[0].id() != FilterId()) {
|
if (list[0].id() != FilterId()) {
|
||||||
filters->moveAllToFront();
|
filters->moveAllToFront();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue