tdesktop/Telegram/SourceFiles/dialogs/dialogs_main_list.h

84 lines
2.0 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
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(const Key &key);
void removeEntry(const Key &key);
2019-04-22 14:22:39 +00:00
void unreadStateChanged(
const UnreadState &wasState,
const UnreadState &nowState);
void unreadEntryChanged(
const Dialogs::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();
auto unreadStateChangeNotifier(bool notify) {
const auto wasState = notify ? unreadState() : UnreadState();
return gsl::finally([=] {
if (notify) {
_unreadStateChanges.fire_copy(wasState);
}
});
}
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;
};
} // namespace Dialogs