mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved out unread state values of main list to separated file.
This commit is contained in:
parent
36924da59a
commit
b11b5caeb3
4 changed files with 86 additions and 38 deletions
|
@ -636,6 +636,8 @@ PRIVATE
|
||||||
data/data_thread.h
|
data/data_thread.h
|
||||||
data/data_types.cpp
|
data/data_types.cpp
|
||||||
data/data_types.h
|
data/data_types.h
|
||||||
|
data/data_unread_value.cpp
|
||||||
|
data/data_unread_value.h
|
||||||
data/data_user.cpp
|
data/data_user.cpp
|
||||||
data/data_user.h
|
data/data_user.h
|
||||||
data/data_user_photos.cpp
|
data/data_user_photos.cpp
|
||||||
|
|
53
Telegram/SourceFiles/data/data_unread_value.cpp
Normal file
53
Telegram/SourceFiles/data/data_unread_value.cpp
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "data/data_unread_value.h"
|
||||||
|
|
||||||
|
#include "data/data_chat_filters.h"
|
||||||
|
#include "data/data_folder.h"
|
||||||
|
#include "data/data_session.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
rpl::producer<Dialogs::UnreadState> MainListUnreadState(
|
||||||
|
not_null<Dialogs::MainList*> list) {
|
||||||
|
return rpl::single(rpl::empty) | rpl::then(
|
||||||
|
list->unreadStateChanges() | rpl::to_empty
|
||||||
|
) | rpl::map([=] {
|
||||||
|
return list->unreadState();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
[[nodiscard]] Dialogs::UnreadState MainListMapUnreadState(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
const Dialogs::UnreadState &state) {
|
||||||
|
const auto folderId = Data::Folder::kId;
|
||||||
|
if (const auto folder = session->data().folderLoaded(folderId)) {
|
||||||
|
return state - folder->chatsList()->unreadState();
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<Dialogs::UnreadState> UnreadStateValue(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
FilterId filterId) {
|
||||||
|
if (filterId > 0) {
|
||||||
|
const auto filters = &session->data().chatsFilters();
|
||||||
|
return MainListUnreadState(filters->chatsList(filterId));
|
||||||
|
}
|
||||||
|
return MainListUnreadState(
|
||||||
|
session->data().chatsList()
|
||||||
|
) | rpl::map([=](const Dialogs::UnreadState &state) {
|
||||||
|
return MainListMapUnreadState(session, state);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Data
|
28
Telegram/SourceFiles/data/data_unread_value.h
Normal file
28
Telegram/SourceFiles/data/data_unread_value.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Dialogs {
|
||||||
|
struct UnreadState;
|
||||||
|
} // namespace Dialogs
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
|
||||||
|
[[nodiscard]] Dialogs::UnreadState MainListMapUnreadState(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
const Dialogs::UnreadState &state);
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<Dialogs::UnreadState> UnreadStateValue(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
FilterId filterId);
|
||||||
|
|
||||||
|
} // namespace Data
|
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
#include "data/data_premium_limits.h"
|
#include "data/data_premium_limits.h"
|
||||||
|
#include "data/data_unread_value.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/filter_icons.h"
|
#include "ui/filter_icons.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
@ -41,42 +42,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
namespace {
|
|
||||||
|
|
||||||
[[nodiscard]] Dialogs::UnreadState MainListMapUnreadState(
|
|
||||||
not_null<Main::Session*> session,
|
|
||||||
const Dialogs::UnreadState &state) {
|
|
||||||
const auto folderId = Data::Folder::kId;
|
|
||||||
if (const auto folder = session->data().folderLoaded(folderId)) {
|
|
||||||
return state - folder->chatsList()->unreadState();
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<Dialogs::UnreadState> MainListUnreadState(
|
|
||||||
not_null<Dialogs::MainList*> list) {
|
|
||||||
return rpl::single(rpl::empty) | rpl::then(
|
|
||||||
list->unreadStateChanges() | rpl::to_empty
|
|
||||||
) | rpl::map([=] {
|
|
||||||
return list->unreadState();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<Dialogs::UnreadState> UnreadStateValue(
|
|
||||||
not_null<Main::Session*> session,
|
|
||||||
FilterId filterId) {
|
|
||||||
if (filterId > 0) {
|
|
||||||
const auto filters = &session->data().chatsFilters();
|
|
||||||
return MainListUnreadState(filters->chatsList(filterId));
|
|
||||||
}
|
|
||||||
return MainListUnreadState(
|
|
||||||
session->data().chatsList()
|
|
||||||
) | rpl::map([=](const Dialogs::UnreadState &state) {
|
|
||||||
return MainListMapUnreadState(session, state);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
FiltersMenu::FiltersMenu(
|
FiltersMenu::FiltersMenu(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
@ -310,7 +275,7 @@ base::unique_qptr<Ui::SideBarButton> FiltersMenu::prepareButton(
|
||||||
raw->setIconOverride(icons.normal, icons.active);
|
raw->setIconOverride(icons.normal, icons.active);
|
||||||
if (id >= 0) {
|
if (id >= 0) {
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
UnreadStateValue(&_session->session(), id),
|
Data::UnreadStateValue(&_session->session(), id),
|
||||||
_includeMuted.value()
|
_includeMuted.value()
|
||||||
) | rpl::start_with_next([=](
|
) | rpl::start_with_next([=](
|
||||||
const Dialogs::UnreadState &state,
|
const Dialogs::UnreadState &state,
|
||||||
|
@ -431,7 +396,7 @@ void FiltersMenu::showMenu(QPoint position, FilterId id) {
|
||||||
} else {
|
} else {
|
||||||
auto customUnreadState = [=] {
|
auto customUnreadState = [=] {
|
||||||
const auto session = &_session->session();
|
const auto session = &_session->session();
|
||||||
return MainListMapUnreadState(
|
return Data::MainListMapUnreadState(
|
||||||
session,
|
session,
|
||||||
session->data().chatsList()->unreadState());
|
session->data().chatsList()->unreadState());
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue