2018-01-04 09:40:58 +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
|
|
|
|
|
2018-01-05 15:57:18 +00:00
|
|
|
#include "dialogs/dialogs_entry.h"
|
2019-04-22 14:22:39 +00:00
|
|
|
#include "dialogs/dialogs_main_list.h"
|
2018-01-09 17:08:31 +00:00
|
|
|
#include "data/data_messages.h"
|
2018-01-05 15:57:18 +00:00
|
|
|
|
2018-01-04 09:40:58 +00:00
|
|
|
class ChannelData;
|
2019-01-15 11:57:45 +00:00
|
|
|
class AuthSession;
|
2018-01-04 09:40:58 +00:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
2018-01-23 16:51:12 +00:00
|
|
|
class Session;
|
2019-04-15 11:54:03 +00:00
|
|
|
class Folder;
|
2018-01-29 13:52:09 +00:00
|
|
|
|
2018-03-06 17:07:42 +00:00
|
|
|
//MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position); // #feed
|
2018-01-05 15:57:18 +00:00
|
|
|
|
2019-04-18 09:00:38 +00:00
|
|
|
class Folder final : public Dialogs::Entry {
|
2018-01-04 09:40:58 +00:00
|
|
|
public:
|
2018-01-23 16:51:12 +00:00
|
|
|
static constexpr auto kId = 1;
|
|
|
|
|
2019-04-15 11:54:03 +00:00
|
|
|
Folder(not_null<Data::Session*> owner, FolderId id);
|
|
|
|
Folder(const Folder &) = delete;
|
|
|
|
Folder &operator=(const Folder &) = delete;
|
2019-01-15 11:57:45 +00:00
|
|
|
|
2019-04-15 11:54:03 +00:00
|
|
|
FolderId id() const;
|
2019-04-16 08:50:59 +00:00
|
|
|
void registerOne(not_null<History*> history);
|
|
|
|
void unregisterOne(not_null<History*> history);
|
2019-04-22 15:09:03 +00:00
|
|
|
void oneListMessageChanged(HistoryItem *from, HistoryItem *to);
|
2018-01-04 09:40:58 +00:00
|
|
|
|
2019-04-22 14:22:39 +00:00
|
|
|
not_null<Dialogs::MainList*> chatsList();
|
2018-01-05 15:57:18 +00:00
|
|
|
|
2019-04-16 08:50:59 +00:00
|
|
|
void applyDialog(const MTPDdialogFolder &data);
|
2019-04-19 08:47:49 +00:00
|
|
|
void applyPinnedUpdate(const MTPDupdateDialogPinned &data);
|
|
|
|
|
2019-04-16 08:50:59 +00:00
|
|
|
//MessagePosition unreadPosition() const; // #feed
|
|
|
|
//rpl::producer<MessagePosition> unreadPositionChanges() const; // #feed
|
|
|
|
|
2019-04-22 14:22:39 +00:00
|
|
|
void updateCloudUnread(const MTPDdialogFolder &data);
|
|
|
|
void unreadStateChanged(
|
2019-04-23 12:29:23 +00:00
|
|
|
const Dialogs::Key &key,
|
2019-04-22 14:22:39 +00:00
|
|
|
const Dialogs::UnreadState &wasState,
|
|
|
|
const Dialogs::UnreadState &nowState);
|
2019-04-23 12:29:23 +00:00
|
|
|
void unreadEntryChanged(
|
|
|
|
const Dialogs::Key &key,
|
|
|
|
const Dialogs::UnreadState &state,
|
|
|
|
bool added);
|
2019-04-19 08:47:49 +00:00
|
|
|
|
2019-04-18 09:00:38 +00:00
|
|
|
TimeId adjustedChatListTimeId() const override;
|
2018-01-31 17:10:29 +00:00
|
|
|
|
2019-04-18 11:31:30 +00:00
|
|
|
int fixedOnTopIndex() const override;
|
2018-01-23 16:51:12 +00:00
|
|
|
bool toImportant() const override;
|
|
|
|
bool shouldBeInChatList() const override;
|
|
|
|
int chatListUnreadCount() const override;
|
2018-06-26 18:03:45 +00:00
|
|
|
bool chatListUnreadMark() const override;
|
2018-01-23 16:51:12 +00:00
|
|
|
bool chatListMutedBadge() const override;
|
2019-04-22 14:22:39 +00:00
|
|
|
Dialogs::UnreadState chatListUnreadState() const override;
|
2019-01-15 11:57:45 +00:00
|
|
|
HistoryItem *chatListMessage() const override;
|
|
|
|
bool chatListMessageKnown() const override;
|
|
|
|
void requestChatListMessage() override;
|
|
|
|
const QString &chatListName() const override;
|
|
|
|
const base::flat_set<QString> &chatListNameWords() const override;
|
|
|
|
const base::flat_set<QChar> &chatListFirstLetters() const override;
|
2018-01-22 09:33:09 +00:00
|
|
|
|
2018-01-05 15:57:18 +00:00
|
|
|
void loadUserpic() override;
|
|
|
|
void paintUserpic(
|
|
|
|
Painter &p,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int size) const override;
|
2018-01-04 19:54:35 +00:00
|
|
|
|
2019-05-16 08:39:45 +00:00
|
|
|
void paintUserpic(
|
|
|
|
Painter &p,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int size,
|
2019-06-17 13:26:08 +00:00
|
|
|
const style::color &overrideBg,
|
|
|
|
const style::color &overrideFg) const;
|
2019-05-16 08:39:45 +00:00
|
|
|
|
2019-04-17 13:22:37 +00:00
|
|
|
bool chatsListLoaded() const;
|
2019-04-22 14:22:39 +00:00
|
|
|
void setChatsListLoaded(bool loaded = true);
|
2019-04-23 12:29:23 +00:00
|
|
|
void setCloudChatsListSize(int size);
|
|
|
|
|
|
|
|
int chatsListSize() const;
|
2019-05-08 08:50:39 +00:00
|
|
|
const std::vector<not_null<History*>> &lastHistories() const;
|
2019-04-23 12:29:23 +00:00
|
|
|
uint32 chatListViewVersion() const;
|
2018-01-29 13:52:09 +00:00
|
|
|
|
2018-01-04 09:40:58 +00:00
|
|
|
private:
|
2018-01-22 09:33:09 +00:00
|
|
|
void indexNameParts();
|
2019-04-22 15:09:03 +00:00
|
|
|
bool applyChatListMessage(HistoryItem *item);
|
|
|
|
void computeChatListMessage();
|
2018-12-04 10:32:06 +00:00
|
|
|
|
2019-05-08 08:50:39 +00:00
|
|
|
void reorderLastHistories();
|
2019-04-25 10:01:09 +00:00
|
|
|
void finalizeCloudUnread();
|
2019-04-23 12:29:23 +00:00
|
|
|
|
2019-06-17 13:26:08 +00:00
|
|
|
void paintUserpic(
|
|
|
|
Painter &p,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int size,
|
|
|
|
const style::color *overrideBg,
|
|
|
|
const style::color *overrideFg) const;
|
|
|
|
|
2019-04-15 11:54:03 +00:00
|
|
|
FolderId _id = 0;
|
2019-04-22 14:22:39 +00:00
|
|
|
Dialogs::MainList _chatsList;
|
2018-01-05 15:57:18 +00:00
|
|
|
|
2018-01-22 09:33:09 +00:00
|
|
|
QString _name;
|
|
|
|
base::flat_set<QString> _nameWords;
|
|
|
|
base::flat_set<QChar> _nameFirstLetters;
|
2018-01-05 15:57:18 +00:00
|
|
|
|
2019-04-22 14:22:39 +00:00
|
|
|
Dialogs::UnreadState _cloudUnread;
|
2019-04-23 12:29:23 +00:00
|
|
|
int _cloudChatsListSize = 0;
|
2019-05-08 08:50:39 +00:00
|
|
|
std::vector<not_null<History*>> _lastHistories;
|
2019-04-22 15:09:03 +00:00
|
|
|
HistoryItem *_chatListMessage = nullptr;
|
2019-04-23 12:29:23 +00:00
|
|
|
uint32 _chatListViewVersion = 0;
|
2019-04-17 13:22:37 +00:00
|
|
|
//rpl::variable<MessagePosition> _unreadPosition;
|
2018-01-04 09:40:58 +00:00
|
|
|
|
2019-04-23 13:28:44 +00:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
2018-01-04 09:40:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Data
|