2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Enable / disable side bar based on filters.

This commit is contained in:
John Preston
2020-03-18 13:19:58 +04:00
parent 3c0ee9fa20
commit 4881981cf6
13 changed files with 41 additions and 32 deletions

View File

@@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_folder.h"
#include "data/data_channel.h"
#include "data/data_chat.h"
#include "data/data_chat_filters.h"
#include "passport/passport_form_controller.h"
#include "chat_helpers/tabbed_selector.h"
#include "core/shortcuts.h"
@@ -135,6 +136,13 @@ SessionController::SessionController(
folder->updateChatListSortPosition();
closeFolder();
}, lifetime());
session->data().chatsFilters().changed(
) | rpl::start_with_next([=] {
crl::on_main(session, [=] {
refreshFiltersMenu();
});
}, session->lifetime());
}
not_null<::MainWindow*> SessionController::widget() const {
@@ -203,6 +211,15 @@ void SessionController::toggleFiltersMenu(bool enabled) {
_window->sideBarChanged();
}
void SessionController::refreshFiltersMenu() {
const auto enabled = !session().data().chatsFilters().list().empty();
if (enabled != Global::DialogsFiltersEnabled()) {
Global::SetDialogsFiltersEnabled(enabled);
session().saveSettingsDelayed();
toggleFiltersMenu(enabled);
}
}
bool SessionController::uniqueChatsInSearchResults() const {
return session().supportMode()
&& !session().settings().supportAllSearchResults()