tdesktop/Telegram/SourceFiles/dialogs/dialogs_main_list.h

88 lines
2.1 KiB
C
Raw Normal View History

2019-04-22 14:22:39 +00:00
/*
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
#include "dialogs/dialogs_indexed_list.h"
#include "dialogs/dialogs_pinned_list.h"
namespace Main {
class Session;
} // namespace Main
namespace Data {
class Thread;
} // namespace Data
2019-04-22 14:22:39 +00:00
namespace Dialogs {
class MainList final {
public:
MainList(
not_null<Main::Session*> session,
FilterId filterId,
rpl::producer<int> pinnedLimit);
2019-04-22 14:22:39 +00:00
bool empty() const;
bool loaded() const;
void setLoaded(bool loaded = true);
void setAllAreMuted(bool allAreMuted = true);
2019-04-22 14:22:39 +00:00
void clear();
RowsByLetter addEntry(Key key);
void removeEntry(Key key);
2019-04-22 14:22:39 +00:00
void unreadStateChanged(
const UnreadState &wasState,
const UnreadState &nowState);
void unreadEntryChanged(const UnreadState &state, bool added);
void updateCloudUnread(const MTPDdialogFolder &data);
[[nodiscard]] bool cloudUnreadKnown() const;
2020-02-07 09:43:12 +00:00
[[nodiscard]] UnreadState unreadState() const;
[[nodiscard]] rpl::producer<UnreadState> unreadStateChanges() const;
[[nodiscard]] not_null<IndexedList*> indexed();
[[nodiscard]] not_null<const IndexedList*> indexed() const;
[[nodiscard]] not_null<PinnedList*> pinned();
[[nodiscard]] not_null<const PinnedList*> pinned() const;
2019-04-22 14:22:39 +00:00
void setCloudListSize(int size);
[[nodiscard]] const rpl::variable<int> &fullSize() const;
2019-04-22 14:22:39 +00:00
private:
void finalizeCloudUnread();
void recomputeFullListSize();
2022-10-20 15:57:15 +00:00
inline auto unreadStateChangeNotifier(bool notify);
FilterId _filterId = 0;
2019-04-22 14:22:39 +00:00
IndexedList _all;
PinnedList _pinned;
UnreadState _unreadState;
UnreadState _cloudUnreadState;
rpl::event_stream<UnreadState> _unreadStateChanges;
rpl::variable<int> _fullListSize = 0;
int _cloudListSize = 0;
2019-04-22 14:22:39 +00:00
bool _loaded = false;
bool _allAreMuted = false;
2019-04-22 14:22:39 +00:00
rpl::lifetime _lifetime;
};
2022-10-20 15:57:15 +00:00
auto MainList::unreadStateChangeNotifier(bool notify) {
const auto wasState = notify ? unreadState() : UnreadState();
return gsl::finally([=] {
if (notify) {
_unreadStateChanges.fire_copy(wasState);
}
});
}
2019-04-22 14:22:39 +00:00
} // namespace Dialogs