Moved edit folders button from folders menu to context menu.

This commit is contained in:
23rd 2023-07-28 03:56:38 +03:00
parent 19ba685cc3
commit a08e42fb97
3 changed files with 22 additions and 11 deletions

View File

@ -3587,6 +3587,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_filters_restore" = "Undo";
"lng_filters_new" = "New Folder";
"lng_filters_edit" = "Edit Folder";
"lng_filters_setup_menu" = "Edit Folders";
"lng_filters_new_name" = "Folder name";
"lng_filters_add_chats" = "Add chats";
"lng_filters_remove_chats" = "Remove chats";

View File

@ -320,17 +320,7 @@ base::unique_qptr<Ui::SideBarButton> FiltersMenu::prepareButton(
} else if (id >= 0) {
_session->setActiveChatsFilter(id);
} else {
const auto filters = &_session->session().data().chatsFilters();
if (filters->suggestedLoaded()) {
_session->showSettings(Settings::Folders::Id());
} else if (!_waitingSuggested) {
_waitingSuggested = true;
filters->requestSuggested();
filters->suggestedUpdated(
) | rpl::take(1) | rpl::start_with_next([=] {
_session->showSettings(Settings::Folders::Id());
}, _outer.lifetime());
}
openFiltersSettings();
}
});
if (id >= 0) {
@ -368,6 +358,20 @@ base::unique_qptr<Ui::SideBarButton> FiltersMenu::prepareButton(
return button;
}
void FiltersMenu::openFiltersSettings() {
const auto filters = &_session->session().data().chatsFilters();
if (filters->suggestedLoaded()) {
_session->showSettings(Settings::Folders::Id());
} else if (!_waitingSuggested) {
_waitingSuggested = true;
filters->requestSuggested();
filters->suggestedUpdated(
) | rpl::take(1) | rpl::start_with_next([=] {
_session->showSettings(Settings::Folders::Id());
}, _outer.lifetime());
}
}
void FiltersMenu::showMenu(QPoint position, FilterId id) {
if (_popupMenu) {
_popupMenu = nullptr;
@ -418,6 +422,11 @@ void FiltersMenu::showMenu(QPoint position, FilterId id) {
[=] { return _session->session().data().chatsList(); },
addAction,
std::move(customUnreadState));
addAction(
tr::lng_filters_setup_menu(tr::now),
[=] { openFiltersSettings(); },
&st::menuIconEdit);
}
if (_popupMenu->empty()) {
_popupMenu = nullptr;

View File

@ -52,6 +52,7 @@ private:
void showRemoveBox(FilterId id);
void remove(FilterId id, std::vector<not_null<PeerData*>> leave = {});
void scrollToButton(not_null<Ui::RpWidget*> widget);
void openFiltersSettings();
const not_null<SessionController*> _session;
const not_null<Ui::RpWidget*> _parent;