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"
|
|
|
|
|
2020-06-12 12:12:34 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
2022-10-20 08:57:12 +00:00
|
|
|
namespace Data {
|
|
|
|
class Thread;
|
|
|
|
} // namespace Data
|
|
|
|
|
2019-04-22 14:22:39 +00:00
|
|
|
namespace Dialogs {
|
|
|
|
|
|
|
|
class MainList final {
|
|
|
|
public:
|
2020-06-12 12:12:34 +00:00
|
|
|
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);
|
2020-03-16 10:20:18 +00:00
|
|
|
void setAllAreMuted(bool allAreMuted = true);
|
2019-04-22 14:22:39 +00:00
|
|
|
void clear();
|
|
|
|
|
2022-11-11 06:23:23 +00:00
|
|
|
RowsByLetter addEntry(Key key);
|
|
|
|
void removeEntry(Key key);
|
2020-03-16 10:20:18 +00:00
|
|
|
|
2019-04-22 14:22:39 +00:00
|
|
|
void unreadStateChanged(
|
|
|
|
const UnreadState &wasState,
|
|
|
|
const UnreadState &nowState);
|
2022-10-20 08:57:12 +00:00
|
|
|
void unreadEntryChanged(const UnreadState &state, bool added);
|
2020-03-16 10:20:18 +00:00
|
|
|
void updateCloudUnread(const MTPDdialogFolder &data);
|
|
|
|
[[nodiscard]] bool cloudUnreadKnown() const;
|
2020-02-07 09:43:12 +00:00
|
|
|
[[nodiscard]] UnreadState unreadState() const;
|
2020-03-16 10:20:18 +00:00
|
|
|
[[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
|
|
|
|
2020-03-16 10:20:18 +00:00
|
|
|
void setCloudListSize(int size);
|
|
|
|
[[nodiscard]] const rpl::variable<int> &fullSize() const;
|
2019-04-22 14:22:39 +00:00
|
|
|
|
|
|
|
private:
|
2020-03-16 10:20:18 +00:00
|
|
|
void finalizeCloudUnread();
|
|
|
|
void recomputeFullListSize();
|
|
|
|
|
2022-10-20 15:57:15 +00:00
|
|
|
inline auto unreadStateChangeNotifier(bool notify);
|
2020-03-16 10:20:18 +00:00
|
|
|
|
2020-03-09 11:17:56 +00:00
|
|
|
FilterId _filterId = 0;
|
2019-04-22 14:22:39 +00:00
|
|
|
IndexedList _all;
|
|
|
|
PinnedList _pinned;
|
|
|
|
UnreadState _unreadState;
|
2020-03-16 10:20:18 +00:00
|
|
|
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;
|
2020-03-16 10:20:18 +00:00
|
|
|
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
|