mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed redundant peer adding to always/never lists in filter from menu.
This commit is contained in:
parent
1493b23574
commit
3dc0e3818b
1 changed files with 20 additions and 9 deletions
|
@ -15,14 +15,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "ui/filter_icons.h"
|
|
||||||
#include "ui/text/text_utilities.h" // Ui::Text::Bold
|
#include "ui/text/text_utilities.h" // Ui::Text::Bold
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "styles/style_settings.h"
|
|
||||||
#include "styles/style_payments.h" // paymentsSectionButton
|
|
||||||
#include "styles/style_media_player.h" // mediaPlayerMenuCheck
|
#include "styles/style_media_player.h" // mediaPlayerMenuCheck
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -32,16 +29,30 @@ Data::ChatFilter ChangedFilter(
|
||||||
not_null<History*> history,
|
not_null<History*> history,
|
||||||
bool add) {
|
bool add) {
|
||||||
auto always = base::duplicate(filter.always());
|
auto always = base::duplicate(filter.always());
|
||||||
if (add) {
|
|
||||||
always.insert(history);
|
|
||||||
} else {
|
|
||||||
always.remove(history);
|
|
||||||
}
|
|
||||||
auto never = base::duplicate(filter.never());
|
auto never = base::duplicate(filter.never());
|
||||||
if (add) {
|
if (add) {
|
||||||
never.remove(history);
|
never.remove(history);
|
||||||
|
const auto result = Data::ChatFilter(
|
||||||
|
filter.id(),
|
||||||
|
filter.title(),
|
||||||
|
filter.iconEmoji(),
|
||||||
|
filter.flags(),
|
||||||
|
filter.always(),
|
||||||
|
filter.pinned(),
|
||||||
|
std::move(never));
|
||||||
|
if (result.contains(history)) {
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
never = base::duplicate(result.never());
|
||||||
|
always.insert(history);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
never.insert(history);
|
const auto alwaysIt = always.find(history);
|
||||||
|
if (alwaysIt != end(always)) {
|
||||||
|
always.erase(alwaysIt);
|
||||||
|
} else {
|
||||||
|
never.insert(history);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Data::ChatFilter(
|
return Data::ChatFilter(
|
||||||
filter.id(),
|
filter.id(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue