2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
#include "data/data_types.h"
|
|
|
|
#include "data/data_peer.h"
|
2020-11-13 17:27:08 +00:00
|
|
|
#include "data/data_drafts.h"
|
2018-01-05 15:57:18 +00:00
|
|
|
#include "dialogs/dialogs_entry.h"
|
2021-10-01 12:42:44 +00:00
|
|
|
#include "dialogs/ui/dialogs_message_view.h"
|
2020-09-29 08:36:30 +00:00
|
|
|
#include "history/view/history_view_send_action.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "base/observer.h"
|
2017-07-17 20:09:55 +00:00
|
|
|
#include "base/timer.h"
|
2017-08-11 07:16:07 +00:00
|
|
|
#include "base/variant.h"
|
|
|
|
#include "base/flat_set.h"
|
2017-08-31 16:28:58 +00:00
|
|
|
#include "base/flags.h"
|
2016-12-01 19:20:33 +00:00
|
|
|
|
2018-01-10 13:13:33 +00:00
|
|
|
class History;
|
2018-01-30 12:32:00 +00:00
|
|
|
class HistoryBlock;
|
|
|
|
class HistoryItem;
|
|
|
|
class HistoryMessage;
|
|
|
|
class HistoryService;
|
2021-10-02 11:28:21 +00:00
|
|
|
struct HistoryMessageMarkupData;
|
2022-01-04 21:11:29 +00:00
|
|
|
class HistoryMainElementDelegateMixin;
|
2019-07-24 11:45:24 +00:00
|
|
|
|
2022-01-26 16:01:40 +00:00
|
|
|
namespace HistoryUnreadThings {
|
|
|
|
enum class AddType;
|
|
|
|
struct All;
|
|
|
|
class Proxy;
|
|
|
|
class ConstProxy;
|
|
|
|
} // namespace HistoryUnreadThings
|
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
2018-01-30 12:32:00 +00:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
struct Draft;
|
2019-01-03 12:36:01 +00:00
|
|
|
class Session;
|
2019-04-16 08:50:59 +00:00
|
|
|
class Folder;
|
2020-03-17 13:04:30 +00:00
|
|
|
class ChatFilter;
|
2021-12-31 12:47:23 +00:00
|
|
|
struct SponsoredFrom;
|
2021-08-31 16:47:38 +00:00
|
|
|
|
|
|
|
enum class ForwardOptions {
|
|
|
|
PreserveInfo,
|
|
|
|
NoSenderNames,
|
|
|
|
NoNamesAndCaptions,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ForwardDraft {
|
|
|
|
MessageIdsList ids;
|
|
|
|
ForwardOptions options = ForwardOptions::PreserveInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ResolvedForwardDraft {
|
|
|
|
HistoryItemsList items;
|
|
|
|
ForwardOptions options = ForwardOptions::PreserveInfo;
|
|
|
|
};
|
|
|
|
|
2018-01-30 12:32:00 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
|
|
|
namespace Dialogs {
|
|
|
|
class Row;
|
|
|
|
class IndexedList;
|
|
|
|
} // namespace Dialogs
|
2014-12-22 23:11:37 +00:00
|
|
|
|
2018-01-22 16:42:25 +00:00
|
|
|
namespace HistoryView {
|
|
|
|
class Element;
|
|
|
|
} // namespace HistoryView
|
|
|
|
|
2019-04-25 12:45:15 +00:00
|
|
|
enum class NewMessageType {
|
|
|
|
Unread,
|
|
|
|
Last,
|
|
|
|
Existing,
|
2015-09-20 08:55:41 +00:00
|
|
|
};
|
|
|
|
|
2022-01-14 13:41:29 +00:00
|
|
|
enum class ItemNotificationType {
|
|
|
|
Message,
|
|
|
|
Reaction,
|
|
|
|
};
|
|
|
|
struct ItemNotification {
|
|
|
|
not_null<HistoryItem*> item;
|
2022-01-31 13:18:40 +00:00
|
|
|
UserData *reactionSender = nullptr;
|
2022-01-14 13:41:29 +00:00
|
|
|
ItemNotificationType type = ItemNotificationType::Message;
|
|
|
|
|
|
|
|
friend inline bool operator==(ItemNotification a, ItemNotification b) {
|
2022-01-31 13:18:40 +00:00
|
|
|
return (a.item == b.item)
|
|
|
|
&& (a.reactionSender == b.reactionSender)
|
|
|
|
&& (a.type == b.type);
|
2022-01-14 13:41:29 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-03 12:36:01 +00:00
|
|
|
class History final : public Dialogs::Entry {
|
2015-09-19 09:13:21 +00:00
|
|
|
public:
|
2018-01-23 16:51:12 +00:00
|
|
|
using Element = HistoryView::Element;
|
|
|
|
|
2019-01-15 11:57:45 +00:00
|
|
|
History(not_null<Data::Session*> owner, PeerId peerId);
|
2016-03-22 09:51:20 +00:00
|
|
|
History(const History &) = delete;
|
|
|
|
History &operator=(const History &) = delete;
|
2019-04-16 08:50:59 +00:00
|
|
|
~History();
|
2016-03-22 09:51:20 +00:00
|
|
|
|
2022-01-04 21:11:29 +00:00
|
|
|
[[nodiscard]] auto delegateMixin() const
|
|
|
|
-> not_null<HistoryMainElementDelegateMixin*> {
|
|
|
|
return _delegateMixin.get();
|
|
|
|
}
|
|
|
|
|
2017-08-31 17:53:03 +00:00
|
|
|
not_null<History*> migrateToOrMe() const;
|
|
|
|
History *migrateFrom() const;
|
2018-01-31 17:10:29 +00:00
|
|
|
MsgRange rangeForDifferenceRequest() const;
|
2019-07-17 12:41:48 +00:00
|
|
|
void checkLocalMessages();
|
2018-05-11 14:03:53 +00:00
|
|
|
void removeJoinedMessage();
|
2017-08-31 17:53:03 +00:00
|
|
|
|
2021-12-28 22:06:01 +00:00
|
|
|
void reactionsEnabledChanged(bool enabled);
|
|
|
|
|
2018-01-31 17:10:29 +00:00
|
|
|
bool isEmpty() const;
|
2016-06-03 12:45:33 +00:00
|
|
|
bool isDisplayedEmpty() const;
|
2019-01-15 11:57:45 +00:00
|
|
|
Element *findFirstNonEmpty() const;
|
2020-09-16 11:28:35 +00:00
|
|
|
Element *findFirstDisplayed() const;
|
2019-01-15 11:57:45 +00:00
|
|
|
Element *findLastNonEmpty() const;
|
2020-09-16 11:28:35 +00:00
|
|
|
Element *findLastDisplayed() const;
|
2017-12-16 13:24:16 +00:00
|
|
|
bool hasOrphanMediaGroupPart() const;
|
|
|
|
bool removeOrphanMediaGroupPart();
|
2021-11-22 17:12:00 +00:00
|
|
|
[[nodiscard]] std::vector<MsgId> collectMessagesFromParticipantToDelete(
|
|
|
|
not_null<PeerData*> participant) const;
|
2016-06-03 12:45:33 +00:00
|
|
|
|
2019-04-08 09:16:45 +00:00
|
|
|
enum class ClearType {
|
|
|
|
Unload,
|
|
|
|
DeleteChat,
|
|
|
|
ClearHistory,
|
|
|
|
};
|
|
|
|
void clear(ClearType type);
|
2017-11-20 19:54:05 +00:00
|
|
|
void clearUpTill(MsgId availableMinId);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2019-07-19 13:34:09 +00:00
|
|
|
void applyGroupAdminChanges(const base::flat_set<UserId> &changes);
|
2017-12-01 18:38:44 +00:00
|
|
|
|
2020-02-20 08:45:25 +00:00
|
|
|
template <typename ...Args>
|
|
|
|
not_null<HistoryMessage*> makeMessage(Args &&...args) {
|
|
|
|
return static_cast<HistoryMessage*>(
|
|
|
|
insertItem(
|
|
|
|
std::make_unique<HistoryMessage>(
|
|
|
|
this,
|
|
|
|
std::forward<Args>(args)...)).get());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename ...Args>
|
|
|
|
not_null<HistoryService*> makeServiceMessage(Args &&...args) {
|
|
|
|
return static_cast<HistoryService*>(
|
|
|
|
insertItem(
|
|
|
|
std::make_unique<HistoryService>(
|
|
|
|
this,
|
|
|
|
std::forward<Args>(args)...)).get());
|
|
|
|
}
|
|
|
|
void destroyMessage(not_null<HistoryItem*> item);
|
2021-11-16 07:26:35 +00:00
|
|
|
void destroyMessagesByDates(TimeId minDate, TimeId maxDate);
|
2020-02-20 08:45:25 +00:00
|
|
|
|
2020-10-30 14:12:04 +00:00
|
|
|
void unpinAllMessages();
|
|
|
|
|
2021-11-05 18:44:28 +00:00
|
|
|
not_null<HistoryItem*> addNewMessage(
|
2021-09-30 11:30:39 +00:00
|
|
|
MsgId id,
|
2019-08-09 19:19:23 +00:00
|
|
|
const MTPMessage &msg,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags localFlags,
|
2019-08-09 19:19:23 +00:00
|
|
|
NewMessageType type);
|
2019-07-17 14:34:39 +00:00
|
|
|
not_null<HistoryItem*> addNewLocalMessage(
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags flags,
|
|
|
|
UserId viaBotId,
|
|
|
|
MsgId replyTo,
|
|
|
|
TimeId date,
|
|
|
|
PeerId from,
|
|
|
|
const QString &postAuthor,
|
|
|
|
const TextWithEntities &text,
|
|
|
|
const MTPMessageMedia &media,
|
2021-10-02 11:28:21 +00:00
|
|
|
HistoryMessageMarkupData &&markup,
|
2021-07-28 11:55:02 +00:00
|
|
|
uint64 groupedId = 0);
|
|
|
|
not_null<HistoryItem*> addNewLocalMessage(
|
|
|
|
MsgId id,
|
|
|
|
MessageFlags flags,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2020-09-01 06:44:18 +00:00
|
|
|
PeerId from,
|
2018-02-03 19:52:35 +00:00
|
|
|
const QString &postAuthor,
|
2021-11-07 08:06:00 +00:00
|
|
|
not_null<HistoryItem*> forwardOriginal);
|
2019-07-17 14:34:39 +00:00
|
|
|
not_null<HistoryItem*> addNewLocalMessage(
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags flags,
|
2018-02-03 19:52:35 +00:00
|
|
|
UserId viaBotId,
|
|
|
|
MsgId replyTo,
|
|
|
|
TimeId date,
|
2020-09-01 06:44:18 +00:00
|
|
|
PeerId from,
|
2018-02-03 19:52:35 +00:00
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
const TextWithEntities &caption,
|
2021-10-02 11:28:21 +00:00
|
|
|
HistoryMessageMarkupData &&markup);
|
2019-07-17 14:34:39 +00:00
|
|
|
not_null<HistoryItem*> addNewLocalMessage(
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags flags,
|
2018-02-03 19:52:35 +00:00
|
|
|
UserId viaBotId,
|
|
|
|
MsgId replyTo,
|
|
|
|
TimeId date,
|
2020-09-01 06:44:18 +00:00
|
|
|
PeerId from,
|
2018-02-03 19:52:35 +00:00
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<PhotoData*> photo,
|
|
|
|
const TextWithEntities &caption,
|
2021-10-02 11:28:21 +00:00
|
|
|
HistoryMessageMarkupData &&markup);
|
2019-07-17 14:34:39 +00:00
|
|
|
not_null<HistoryItem*> addNewLocalMessage(
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags flags,
|
2018-02-03 19:52:35 +00:00
|
|
|
UserId viaBotId,
|
|
|
|
MsgId replyTo,
|
|
|
|
TimeId date,
|
2020-09-01 06:44:18 +00:00
|
|
|
PeerId from,
|
2018-02-03 19:52:35 +00:00
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<GameData*> game,
|
2021-10-02 11:28:21 +00:00
|
|
|
HistoryMessageMarkupData &&markup);
|
2021-12-31 12:47:23 +00:00
|
|
|
not_null<HistoryItem*> addNewLocalMessage(
|
|
|
|
MsgId id,
|
|
|
|
Data::SponsoredFrom from,
|
|
|
|
const TextWithEntities &textWithEntities); // sponsored
|
2015-01-02 14:55:24 +00:00
|
|
|
|
2017-06-18 13:08:49 +00:00
|
|
|
// Used only internally and for channel admin log.
|
2021-11-05 18:44:28 +00:00
|
|
|
not_null<HistoryItem*> createItem(
|
2021-09-30 11:30:39 +00:00
|
|
|
MsgId id,
|
2018-01-14 16:02:25 +00:00
|
|
|
const MTPMessage &message,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags localFlags,
|
2018-01-14 16:02:25 +00:00
|
|
|
bool detachExistingItem);
|
2018-01-17 16:21:01 +00:00
|
|
|
std::vector<not_null<HistoryItem*>> createItems(
|
|
|
|
const QVector<MTPMessage> &data);
|
2017-06-18 13:08:49 +00:00
|
|
|
|
2016-05-27 16:47:46 +00:00
|
|
|
void addOlderSlice(const QVector<MTPMessage> &slice);
|
|
|
|
void addNewerSlice(const QVector<MTPMessage> &slice);
|
2014-07-04 11:12:54 +00:00
|
|
|
|
2017-12-21 12:11:33 +00:00
|
|
|
void newItemAdded(not_null<HistoryItem*> item);
|
2014-07-04 11:12:54 +00:00
|
|
|
|
2021-11-07 08:06:00 +00:00
|
|
|
void registerClientSideMessage(not_null<HistoryItem*> item);
|
|
|
|
void unregisterClientSideMessage(not_null<HistoryItem*> item);
|
|
|
|
[[nodiscard]] auto clientSideMessages()
|
2020-09-04 16:11:36 +00:00
|
|
|
-> const base::flat_set<not_null<HistoryItem*>> &;
|
2019-07-17 14:34:39 +00:00
|
|
|
[[nodiscard]] HistoryItem *latestSendingMessage() const;
|
2019-07-17 12:41:48 +00:00
|
|
|
|
2020-02-18 11:39:24 +00:00
|
|
|
[[nodiscard]] bool readInboxTillNeedsRequest(MsgId tillId);
|
2019-04-23 09:40:14 +00:00
|
|
|
void applyInboxReadUpdate(
|
|
|
|
FolderId folderId,
|
|
|
|
MsgId upTo,
|
|
|
|
int stillUnread,
|
|
|
|
int32 channelPts = 0);
|
|
|
|
void inboxRead(MsgId upTo, std::optional<int> stillUnread = {});
|
2018-01-31 17:10:29 +00:00
|
|
|
void inboxRead(not_null<const HistoryItem*> wasRead);
|
|
|
|
void outboxRead(MsgId upTo);
|
|
|
|
void outboxRead(not_null<const HistoryItem*> wasRead);
|
2019-08-30 14:06:21 +00:00
|
|
|
[[nodiscard]] bool isServerSideUnread(
|
|
|
|
not_null<const HistoryItem*> item) const;
|
|
|
|
[[nodiscard]] MsgId loadAroundId() const;
|
2020-09-18 11:52:44 +00:00
|
|
|
[[nodiscard]] MsgId inboxReadTillId() const;
|
|
|
|
[[nodiscard]] MsgId outboxReadTillId() const;
|
2018-01-31 17:10:29 +00:00
|
|
|
|
2020-02-21 07:34:24 +00:00
|
|
|
[[nodiscard]] bool trackUnreadMessages() const;
|
2019-08-30 14:06:21 +00:00
|
|
|
[[nodiscard]] int unreadCount() const;
|
|
|
|
[[nodiscard]] bool unreadCountKnown() const;
|
2020-02-11 11:23:51 +00:00
|
|
|
|
|
|
|
// Some old unread count is known, but we read history till some place.
|
2020-02-18 11:39:24 +00:00
|
|
|
[[nodiscard]] bool unreadCountRefreshNeeded(MsgId readTillId) const;
|
2020-02-11 11:23:51 +00:00
|
|
|
|
2016-04-14 19:24:42 +00:00
|
|
|
void setUnreadCount(int newUnreadCount);
|
2018-06-26 18:03:45 +00:00
|
|
|
void setUnreadMark(bool unread);
|
2019-08-30 14:06:21 +00:00
|
|
|
[[nodiscard]] bool unreadMark() const;
|
2020-03-20 15:19:55 +00:00
|
|
|
void setFakeUnreadWhileOpened(bool enabled);
|
|
|
|
[[nodiscard]] bool fakeUnreadWhileOpened() const;
|
2019-08-30 14:06:21 +00:00
|
|
|
[[nodiscard]] int unreadCountForBadge() const; // unreadCount || unreadMark ? 1 : 0.
|
|
|
|
[[nodiscard]] bool mute() const;
|
2017-12-04 17:46:03 +00:00
|
|
|
bool changeMute(bool newMute);
|
2014-05-30 08:53:19 +00:00
|
|
|
void addUnreadBar();
|
2016-03-18 19:05:08 +00:00
|
|
|
void destroyUnreadBar();
|
2019-08-30 14:06:21 +00:00
|
|
|
[[nodiscard]] Element *unreadBar() const;
|
2018-01-21 19:21:08 +00:00
|
|
|
void calculateFirstUnreadMessage();
|
|
|
|
void unsetFirstUnreadMessage();
|
2019-08-30 14:06:21 +00:00
|
|
|
[[nodiscard]] Element *firstUnreadMessage() const;
|
2014-07-04 11:12:54 +00:00
|
|
|
void clearNotifications();
|
2019-08-30 14:06:21 +00:00
|
|
|
void clearIncomingNotifications();
|
2014-07-04 11:12:54 +00:00
|
|
|
|
2019-08-30 14:06:21 +00:00
|
|
|
[[nodiscard]] bool loadedAtBottom() const; // last message is in the list
|
2015-09-13 08:41:27 +00:00
|
|
|
void setNotLoadedAtBottom();
|
2019-08-30 14:06:21 +00:00
|
|
|
[[nodiscard]] bool loadedAtTop() const; // nothing was added after loading history back
|
|
|
|
[[nodiscard]] bool isReadyFor(MsgId msgId); // has messages for showing history at msgId
|
2016-05-27 16:47:46 +00:00
|
|
|
void getReadyFor(MsgId msgId);
|
2014-07-04 11:12:54 +00:00
|
|
|
|
2019-08-30 14:06:21 +00:00
|
|
|
[[nodiscard]] HistoryItem *lastMessage() const;
|
2020-02-19 15:35:26 +00:00
|
|
|
[[nodiscard]] HistoryItem *lastServerMessage() const;
|
2019-08-30 14:06:21 +00:00
|
|
|
[[nodiscard]] bool lastMessageKnown() const;
|
2020-02-19 15:35:26 +00:00
|
|
|
[[nodiscard]] bool lastServerMessageKnown() const;
|
2018-01-31 17:10:29 +00:00
|
|
|
void unknownMessageDeleted(MsgId messageId);
|
|
|
|
void applyDialogTopMessage(MsgId topMessageId);
|
2019-04-22 14:22:39 +00:00
|
|
|
void applyDialog(Data::Folder *requestFolder, const MTPDdialog &data);
|
2019-04-19 08:47:49 +00:00
|
|
|
void applyPinnedUpdate(const MTPDupdateDialogPinned &data);
|
2018-01-31 17:10:29 +00:00
|
|
|
void applyDialogFields(
|
2019-04-22 14:22:39 +00:00
|
|
|
Data::Folder *folder,
|
2018-01-31 17:10:29 +00:00
|
|
|
int unreadCount,
|
|
|
|
MsgId maxInboxRead,
|
|
|
|
MsgId maxOutboxRead);
|
2019-01-15 11:57:45 +00:00
|
|
|
void dialogEntryApplied();
|
2014-07-04 11:12:54 +00:00
|
|
|
|
2020-04-29 08:46:02 +00:00
|
|
|
void cacheTopPromotion(
|
|
|
|
bool promoted,
|
|
|
|
const QString &type,
|
|
|
|
const QString &message);
|
2021-10-19 13:00:21 +00:00
|
|
|
[[nodiscard]] QStringView topPromotionType() const;
|
2020-04-29 08:46:02 +00:00
|
|
|
[[nodiscard]] QString topPromotionMessage() const;
|
2020-04-30 11:20:50 +00:00
|
|
|
[[nodiscard]] bool topPromotionAboutShown() const;
|
|
|
|
void markTopPromotionAboutShown();
|
2020-04-29 08:46:02 +00:00
|
|
|
|
2014-07-04 11:12:54 +00:00
|
|
|
MsgId minMsgId() const;
|
|
|
|
MsgId maxMsgId() const;
|
2015-09-06 10:17:09 +00:00
|
|
|
MsgId msgIdForRead() const;
|
2021-01-10 21:10:29 +00:00
|
|
|
HistoryItem *lastEditableMessage() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-21 19:21:08 +00:00
|
|
|
void resizeToWidth(int newWidth);
|
2019-08-06 11:27:11 +00:00
|
|
|
void forceFullResize();
|
2018-01-31 17:10:29 +00:00
|
|
|
int height() const;
|
2014-07-04 11:12:54 +00:00
|
|
|
|
2018-01-31 17:10:29 +00:00
|
|
|
void itemRemoved(not_null<HistoryItem*> item);
|
|
|
|
void itemVanished(not_null<HistoryItem*> item);
|
2014-07-04 11:12:54 +00:00
|
|
|
|
2022-01-14 13:41:29 +00:00
|
|
|
[[nodiscard]] std::optional<ItemNotification> currentNotification() const;
|
2018-01-31 17:10:29 +00:00
|
|
|
bool hasNotification() const;
|
|
|
|
void skipNotification();
|
2022-01-14 13:41:29 +00:00
|
|
|
void pushNotification(ItemNotification notification);
|
|
|
|
void popNotification(ItemNotification notification);
|
2018-01-31 17:10:29 +00:00
|
|
|
|
|
|
|
bool hasPendingResizedItems() const;
|
2016-03-19 16:55:15 +00:00
|
|
|
void setHasPendingResizedItems();
|
|
|
|
|
2020-09-29 08:36:30 +00:00
|
|
|
[[nodiscard]] auto sendActionPainter()
|
|
|
|
-> not_null<HistoryView::SendActionPainter*> {
|
|
|
|
return &_sendActionPainter;
|
|
|
|
}
|
2017-12-07 14:27:59 +00:00
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
void clearLastKeyboard();
|
|
|
|
|
2022-01-26 16:01:40 +00:00
|
|
|
void setUnreadThingsKnown();
|
|
|
|
[[nodiscard]] HistoryUnreadThings::Proxy unreadMentions();
|
|
|
|
[[nodiscard]] HistoryUnreadThings::ConstProxy unreadMentions() const;
|
|
|
|
[[nodiscard]] HistoryUnreadThings::Proxy unreadReactions();
|
|
|
|
[[nodiscard]] HistoryUnreadThings::ConstProxy unreadReactions() const;
|
2017-08-11 07:16:07 +00:00
|
|
|
|
2020-11-13 17:27:08 +00:00
|
|
|
Data::Draft *draft(Data::DraftKey key) const;
|
|
|
|
void setDraft(Data::DraftKey key, std::unique_ptr<Data::Draft> &&draft);
|
|
|
|
void clearDraft(Data::DraftKey key);
|
|
|
|
|
|
|
|
[[nodiscard]] const Data::HistoryDrafts &draftsMap() const;
|
|
|
|
void setDraftsMap(Data::HistoryDrafts &&map);
|
|
|
|
|
2018-01-05 15:57:18 +00:00
|
|
|
Data::Draft *localDraft() const {
|
2020-11-13 17:27:08 +00:00
|
|
|
return draft(Data::DraftKey::Local());
|
|
|
|
}
|
|
|
|
Data::Draft *localEditDraft() const {
|
|
|
|
return draft(Data::DraftKey::LocalEdit());
|
2016-06-03 18:24:27 +00:00
|
|
|
}
|
2018-01-05 15:57:18 +00:00
|
|
|
Data::Draft *cloudDraft() const {
|
2020-11-13 17:27:08 +00:00
|
|
|
return draft(Data::DraftKey::Cloud());
|
|
|
|
}
|
|
|
|
void setLocalDraft(std::unique_ptr<Data::Draft> &&draft) {
|
|
|
|
setDraft(Data::DraftKey::Local(), std::move(draft));
|
|
|
|
}
|
|
|
|
void setLocalEditDraft(std::unique_ptr<Data::Draft> &&draft) {
|
|
|
|
setDraft(Data::DraftKey::LocalEdit(), std::move(draft));
|
2016-04-08 14:16:52 +00:00
|
|
|
}
|
2020-11-13 17:27:08 +00:00
|
|
|
void setCloudDraft(std::unique_ptr<Data::Draft> &&draft) {
|
|
|
|
setDraft(Data::DraftKey::Cloud(), std::move(draft));
|
2016-04-08 14:16:52 +00:00
|
|
|
}
|
2020-11-13 17:27:08 +00:00
|
|
|
void clearLocalDraft() {
|
|
|
|
clearDraft(Data::DraftKey::Local());
|
|
|
|
}
|
|
|
|
void clearCloudDraft() {
|
|
|
|
clearDraft(Data::DraftKey::Cloud());
|
|
|
|
}
|
|
|
|
void clearLocalEditDraft() {
|
|
|
|
clearDraft(Data::DraftKey::LocalEdit());
|
|
|
|
}
|
|
|
|
void clearDrafts();
|
2018-11-15 15:36:04 +00:00
|
|
|
Data::Draft *createCloudDraft(const Data::Draft *fromDraft);
|
2021-03-12 11:18:33 +00:00
|
|
|
bool skipCloudDraftUpdate(TimeId date) const;
|
|
|
|
void startSavingCloudDraft();
|
|
|
|
void finishSavingCloudDraft(TimeId savedAt);
|
2020-11-13 17:27:08 +00:00
|
|
|
void takeLocalDraft(not_null<History*> from);
|
2019-03-12 12:54:15 +00:00
|
|
|
void applyCloudDraft();
|
2016-06-09 14:31:10 +00:00
|
|
|
void draftSavedToCloud();
|
2016-02-25 10:32:31 +00:00
|
|
|
|
2021-08-31 16:47:38 +00:00
|
|
|
[[nodiscard]] const Data::ForwardDraft &forwardDraft() const {
|
2017-06-16 20:33:35 +00:00
|
|
|
return _forwardDraft;
|
|
|
|
}
|
2021-08-31 16:47:38 +00:00
|
|
|
[[nodiscard]] Data::ResolvedForwardDraft resolveForwardDraft(
|
|
|
|
const Data::ForwardDraft &draft) const;
|
|
|
|
[[nodiscard]] Data::ResolvedForwardDraft resolveForwardDraft();
|
|
|
|
void setForwardDraft(Data::ForwardDraft &&draft);
|
2017-06-16 20:33:35 +00:00
|
|
|
|
2018-06-26 18:03:45 +00:00
|
|
|
History *migrateSibling() const;
|
2020-04-24 12:40:20 +00:00
|
|
|
[[nodiscard]] bool useTopPromotion() const;
|
2019-04-18 11:31:30 +00:00
|
|
|
int fixedOnTopIndex() const override;
|
2018-01-29 17:13:24 +00:00
|
|
|
void updateChatListExistence() override;
|
2018-01-23 16:51:12 +00:00
|
|
|
bool shouldBeInChatList() const override;
|
2018-01-05 15:57:18 +00:00
|
|
|
int chatListUnreadCount() const override;
|
2018-06-26 18:03:45 +00:00
|
|
|
bool chatListUnreadMark() const override;
|
2018-01-05 15:57:18 +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;
|
2021-02-19 11:54:27 +00:00
|
|
|
const QString &chatListNameSortKey() const override;
|
2019-01-15 11:57:45 +00:00
|
|
|
const base::flat_set<QString> &chatListNameWords() const override;
|
|
|
|
const base::flat_set<QChar> &chatListFirstLetters() const override;
|
2018-01-05 15:57:18 +00:00
|
|
|
void loadUserpic() override;
|
|
|
|
void paintUserpic(
|
|
|
|
Painter &p,
|
2020-05-28 14:32:10 +00:00
|
|
|
std::shared_ptr<Data::CloudImageView> &view,
|
2018-01-05 15:57:18 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int size) const override;
|
|
|
|
|
2021-02-19 11:54:27 +00:00
|
|
|
void refreshChatListNameSortKey();
|
|
|
|
|
2019-01-15 11:57:45 +00:00
|
|
|
void setFakeChatListMessageFrom(const MTPmessages_Messages &data);
|
|
|
|
void checkChatListMessageRemoved(not_null<HistoryItem*> item);
|
|
|
|
|
2021-10-04 19:37:55 +00:00
|
|
|
void applyChatListGroup(
|
2021-12-09 07:32:54 +00:00
|
|
|
PeerId dataPeerId,
|
2021-10-04 19:37:55 +00:00
|
|
|
const MTPmessages_Messages &data);
|
|
|
|
|
2018-01-21 19:21:08 +00:00
|
|
|
void forgetScrollState() {
|
|
|
|
scrollTopItem = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// find the correct scrollTopItem and scrollTopOffset using given top
|
|
|
|
// of the displayed window relative to the history start coordinate
|
|
|
|
void countScrollState(int top);
|
|
|
|
|
2020-10-09 16:23:53 +00:00
|
|
|
[[nodiscard]] std::pair<Element*, int> findItemAndOffset(int top) const;
|
|
|
|
|
2021-09-30 11:30:39 +00:00
|
|
|
[[nodiscard]] MsgId nextNonHistoryEntryId();
|
2018-01-22 16:42:25 +00:00
|
|
|
|
2019-04-18 09:00:38 +00:00
|
|
|
bool folderKnown() const override;
|
2019-04-17 13:22:37 +00:00
|
|
|
Data::Folder *folder() const override;
|
|
|
|
void setFolder(
|
|
|
|
not_null<Data::Folder*> folder,
|
|
|
|
HistoryItem *folderDialogItem = nullptr);
|
2019-04-16 08:50:59 +00:00
|
|
|
void clearFolder();
|
2018-01-21 19:21:08 +00:00
|
|
|
|
2020-02-18 11:39:24 +00:00
|
|
|
// Interface for Data::Histories.
|
|
|
|
void setInboxReadTill(MsgId upTo);
|
|
|
|
std::optional<int> countStillUnreadLocal(MsgId readTillId) const;
|
|
|
|
|
2021-08-26 13:25:48 +00:00
|
|
|
[[nodiscard]] bool hasPinnedMessages() const;
|
|
|
|
void setHasPinnedMessages(bool has);
|
|
|
|
|
2018-01-21 19:21:08 +00:00
|
|
|
// Still public data.
|
|
|
|
std::deque<std::unique_ptr<HistoryBlock>> blocks;
|
|
|
|
|
|
|
|
not_null<PeerData*> peer;
|
|
|
|
|
2016-03-21 18:40:00 +00:00
|
|
|
// we save the last showAtMsgId to restore the state when switching
|
|
|
|
// between different conversation histories
|
2016-04-08 14:16:52 +00:00
|
|
|
MsgId showAtMsgId = ShowAtUnreadMsgId;
|
2016-03-21 18:40:00 +00:00
|
|
|
|
|
|
|
// we save a pointer of the history item at the top of the displayed window
|
|
|
|
// together with an offset from the window top to the top of this message
|
|
|
|
// resulting scrollTop = top(scrollTopItem) + scrollTopOffset
|
2018-01-23 16:51:12 +00:00
|
|
|
Element *scrollTopItem = nullptr;
|
2016-04-08 14:16:52 +00:00
|
|
|
int scrollTopOffset = 0;
|
2016-03-21 18:40:00 +00:00
|
|
|
|
2016-04-08 14:16:52 +00:00
|
|
|
bool lastKeyboardInited = false;
|
|
|
|
bool lastKeyboardUsed = false;
|
|
|
|
MsgId lastKeyboardId = 0;
|
|
|
|
MsgId lastKeyboardHiddenId = 0;
|
|
|
|
PeerId lastKeyboardFrom = 0;
|
2015-06-15 17:19:24 +00:00
|
|
|
|
2016-04-08 14:16:52 +00:00
|
|
|
mtpRequestId sendRequestId = 0;
|
2014-11-05 17:43:32 +00:00
|
|
|
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String cloudDraftTextCache;
|
2021-10-01 12:42:44 +00:00
|
|
|
Dialogs::Ui::MessageView lastItemDialogsView;
|
2016-06-03 18:24:27 +00:00
|
|
|
|
2018-01-31 17:10:29 +00:00
|
|
|
private:
|
|
|
|
friend class HistoryBlock;
|
|
|
|
|
|
|
|
enum class Flag {
|
2022-01-26 16:01:40 +00:00
|
|
|
HasPendingResizedItems = (1 << 0),
|
|
|
|
UnreadThingsKnown = (1 << 1),
|
2018-01-31 17:10:29 +00:00
|
|
|
};
|
|
|
|
using Flags = base::flags<Flag>;
|
|
|
|
friend inline constexpr auto is_flag_type(Flag) {
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2018-01-21 19:21:08 +00:00
|
|
|
// when this item is destroyed scrollTopItem just points to the next one
|
|
|
|
// and scrollTopOffset remains the same
|
|
|
|
// if we are at the bottom of the window scrollTopItem == nullptr and
|
|
|
|
// scrollTopOffset is undefined
|
|
|
|
void getNextScrollTopItem(HistoryBlock *block, int32 i);
|
|
|
|
|
|
|
|
// helper method for countScrollState(int top)
|
2020-10-09 16:23:53 +00:00
|
|
|
[[nodiscard]] Element *findScrollTopItem(int top) const;
|
2018-01-21 19:21:08 +00:00
|
|
|
|
2016-03-31 10:37:58 +00:00
|
|
|
// this method just removes a block from the blocks list
|
|
|
|
// when the last item from this block was detached and
|
|
|
|
// calls the required previousItemChanged()
|
2017-12-13 18:10:48 +00:00
|
|
|
void removeBlock(not_null<HistoryBlock*> block);
|
2019-04-08 09:16:45 +00:00
|
|
|
void clearSharedMedia();
|
2016-03-31 10:37:58 +00:00
|
|
|
|
2020-02-20 08:45:25 +00:00
|
|
|
not_null<HistoryItem*> insertItem(std::unique_ptr<HistoryItem> item);
|
2018-01-14 16:02:25 +00:00
|
|
|
not_null<HistoryItem*> addNewItem(
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
bool unread);
|
2019-08-12 16:33:36 +00:00
|
|
|
not_null<HistoryItem*> addNewToBack(
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
bool unread);
|
2018-01-10 13:13:33 +00:00
|
|
|
not_null<HistoryItem*> addNewInTheMiddle(
|
2018-01-14 16:02:25 +00:00
|
|
|
not_null<HistoryItem*> item,
|
2018-01-10 13:13:33 +00:00
|
|
|
int blockIndex,
|
|
|
|
int itemIndex);
|
2016-03-31 10:37:58 +00:00
|
|
|
|
|
|
|
// All this methods add a new item to the first or last block
|
|
|
|
// depending on if we are in isBuildingFronBlock() state.
|
|
|
|
// The last block is created on the go if it is needed.
|
|
|
|
|
|
|
|
// Adds the item to the back or front block, depending on
|
|
|
|
// isBuildingFrontBlock(), creating the block if necessary.
|
2017-12-13 18:10:48 +00:00
|
|
|
void addItemToBlock(not_null<HistoryItem*> item);
|
2016-03-31 10:37:58 +00:00
|
|
|
|
|
|
|
// Usually all new items are added to the last block.
|
|
|
|
// Only when we scroll up and add a new slice to the
|
|
|
|
// front we want to create a new front block.
|
|
|
|
void startBuildingFrontBlock(int expectedItemsCount = 1);
|
2018-01-30 10:51:35 +00:00
|
|
|
void finishBuildingFrontBlock();
|
2016-03-31 10:37:58 +00:00
|
|
|
bool isBuildingFrontBlock() const {
|
2016-04-10 19:20:48 +00:00
|
|
|
return _buildingFrontBlock != nullptr;
|
2016-03-31 10:37:58 +00:00
|
|
|
}
|
|
|
|
|
2021-10-04 19:37:55 +00:00
|
|
|
void addCreatedOlderSlice(
|
|
|
|
const std::vector<not_null<HistoryItem*>> &items);
|
|
|
|
|
2019-01-22 07:50:21 +00:00
|
|
|
void checkForLoadedAtTop(not_null<HistoryItem*> added);
|
2018-01-21 19:21:08 +00:00
|
|
|
void mainViewRemoved(
|
|
|
|
not_null<HistoryBlock*> block,
|
2018-01-23 16:51:12 +00:00
|
|
|
not_null<Element*> view);
|
2018-01-31 17:10:29 +00:00
|
|
|
void removeNotification(not_null<HistoryItem*> item);
|
2018-01-21 19:21:08 +00:00
|
|
|
|
2019-04-18 09:00:38 +00:00
|
|
|
TimeId adjustedChatListTimeId() const override;
|
2018-01-05 15:57:18 +00:00
|
|
|
void changedChatListPinHook() override;
|
|
|
|
|
2018-01-31 17:10:29 +00:00
|
|
|
void setOutboxReadTill(MsgId upTo);
|
2019-04-30 09:48:48 +00:00
|
|
|
void readClientSideMessages();
|
2018-01-31 17:10:29 +00:00
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
void applyMessageChanges(
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
const MTPMessage &original);
|
|
|
|
void applyServiceChanges(
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
const MTPDmessageService &data);
|
|
|
|
|
2018-02-05 14:37:22 +00:00
|
|
|
// After adding a new history slice check lastMessage / loadedAtBottom.
|
2018-01-31 17:10:29 +00:00
|
|
|
void checkLastMessage();
|
|
|
|
void setLastMessage(HistoryItem *item);
|
2020-02-19 13:49:49 +00:00
|
|
|
void setLastServerMessage(HistoryItem *item);
|
2016-04-11 07:43:40 +00:00
|
|
|
|
2019-01-15 11:57:45 +00:00
|
|
|
void refreshChatListMessage();
|
|
|
|
void setChatListMessage(HistoryItem *item);
|
|
|
|
std::optional<HistoryItem*> computeChatListMessageFromLast() const;
|
|
|
|
void setChatListMessageFromLast();
|
2019-04-22 15:09:03 +00:00
|
|
|
void setChatListMessageUnknown();
|
2019-01-15 11:57:45 +00:00
|
|
|
void setFakeChatListMessage();
|
|
|
|
|
2017-12-08 18:27:28 +00:00
|
|
|
// Add all items to the unread mentions if we were not loaded at bottom and now are.
|
|
|
|
void checkAddAllToUnreadMentions();
|
2016-08-14 19:15:45 +00:00
|
|
|
|
2018-01-17 16:21:01 +00:00
|
|
|
void addToSharedMedia(const std::vector<not_null<HistoryItem*>> &items);
|
|
|
|
void addEdgesToSharedMedia();
|
2017-09-04 11:40:02 +00:00
|
|
|
|
2018-01-17 16:21:01 +00:00
|
|
|
void addItemsToLists(const std::vector<not_null<HistoryItem*>> &items);
|
2018-10-08 13:41:14 +00:00
|
|
|
bool clearUnreadOnClientSide() const;
|
|
|
|
bool skipUnreadUpdate() const;
|
2017-12-07 14:27:59 +00:00
|
|
|
|
2018-01-21 19:21:08 +00:00
|
|
|
HistoryItem *lastAvailableMessage() const;
|
|
|
|
void getNextFirstUnreadMessage();
|
2019-01-22 07:50:21 +00:00
|
|
|
bool nonEmptyCountMoreThan(int count) const;
|
2018-01-21 19:21:08 +00:00
|
|
|
|
|
|
|
// Creates if necessary a new block for adding item.
|
|
|
|
// Depending on isBuildingFrontBlock() gets front or back block.
|
|
|
|
HistoryBlock *prepareBlockForAddingItem();
|
2017-08-31 16:28:58 +00:00
|
|
|
|
2018-01-23 16:51:12 +00:00
|
|
|
void viewReplaced(not_null<const Element*> was, Element *now);
|
|
|
|
|
2019-03-12 12:54:15 +00:00
|
|
|
void createLocalDraftFromCloud();
|
|
|
|
|
2019-07-17 12:41:48 +00:00
|
|
|
HistoryService *insertJoinedMessage();
|
2021-11-08 05:41:50 +00:00
|
|
|
void insertMessageToBlocks(not_null<HistoryItem*> item);
|
2019-07-17 12:41:48 +00:00
|
|
|
|
2019-04-16 08:50:59 +00:00
|
|
|
void setFolderPointer(Data::Folder *folder);
|
|
|
|
|
2022-01-04 21:11:29 +00:00
|
|
|
const std::unique_ptr<HistoryMainElementDelegateMixin> _delegateMixin;
|
|
|
|
|
2017-08-31 16:28:58 +00:00
|
|
|
Flags _flags = 0;
|
2017-08-11 07:16:07 +00:00
|
|
|
bool _mute = false;
|
2018-01-21 19:21:08 +00:00
|
|
|
int _width = 0;
|
|
|
|
int _height = 0;
|
2018-01-23 16:51:12 +00:00
|
|
|
Element *_unreadBarView = nullptr;
|
|
|
|
Element *_firstUnreadView = nullptr;
|
2018-01-31 17:10:29 +00:00
|
|
|
HistoryService *_joinedMessage = nullptr;
|
2018-02-05 14:37:22 +00:00
|
|
|
bool _loadedAtTop = false;
|
|
|
|
bool _loadedAtBottom = true;
|
2017-08-11 07:16:07 +00:00
|
|
|
|
2019-04-18 09:00:38 +00:00
|
|
|
std::optional<Data::Folder*> _folder;
|
2019-04-16 08:50:59 +00:00
|
|
|
|
2018-09-21 16:28:46 +00:00
|
|
|
std::optional<MsgId> _inboxReadBefore;
|
|
|
|
std::optional<MsgId> _outboxReadBefore;
|
|
|
|
std::optional<int> _unreadCount;
|
|
|
|
std::optional<HistoryItem*> _lastMessage;
|
2020-02-19 15:35:26 +00:00
|
|
|
std::optional<HistoryItem*> _lastServerMessage;
|
2021-11-07 08:06:00 +00:00
|
|
|
base::flat_set<not_null<HistoryItem*>> _clientSideMessages;
|
2020-02-20 08:45:25 +00:00
|
|
|
std::unordered_set<std::unique_ptr<HistoryItem>> _messages;
|
2022-01-26 16:01:40 +00:00
|
|
|
std::unique_ptr<HistoryUnreadThings::All> _unreadThings;
|
2019-01-15 11:57:45 +00:00
|
|
|
|
|
|
|
// This almost always is equal to _lastMessage. The only difference is
|
|
|
|
// for a group that migrated to a supergroup. Then _lastMessage can
|
|
|
|
// be a migrate message, but _chatListMessage should be the one before.
|
|
|
|
std::optional<HistoryItem*> _chatListMessage;
|
|
|
|
|
2021-02-19 11:54:27 +00:00
|
|
|
QString _chatListNameSortKey;
|
|
|
|
|
2018-06-26 18:03:45 +00:00
|
|
|
bool _unreadMark = false;
|
2020-03-20 15:19:55 +00:00
|
|
|
bool _fakeUnreadWhileOpened = false;
|
2021-08-26 13:25:48 +00:00
|
|
|
bool _hasPinnedMessages = false;
|
2016-03-19 16:55:15 +00:00
|
|
|
|
2016-03-31 10:37:58 +00:00
|
|
|
// A pointer to the block that is currently being built.
|
|
|
|
// We hold this pointer so we can destroy it while building
|
|
|
|
// and then create a new one if it is necessary.
|
|
|
|
struct BuildingBlock {
|
|
|
|
int expectedItemsCount = 0; // optimization for block->items.reserve() call
|
|
|
|
HistoryBlock *block = nullptr;
|
|
|
|
};
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<BuildingBlock> _buildingFrontBlock;
|
2015-09-19 09:13:21 +00:00
|
|
|
|
2020-11-13 17:27:08 +00:00
|
|
|
Data::HistoryDrafts _drafts;
|
2021-03-12 11:18:33 +00:00
|
|
|
TimeId _acceptCloudDraftsAfter = 0;
|
|
|
|
int _savingCloudDraftRequests = 0;
|
2021-08-31 16:47:38 +00:00
|
|
|
Data::ForwardDraft _forwardDraft;
|
2016-04-08 14:16:52 +00:00
|
|
|
|
2020-04-29 08:46:02 +00:00
|
|
|
QString _topPromotedMessage;
|
|
|
|
QString _topPromotedType;
|
|
|
|
|
2020-09-29 08:36:30 +00:00
|
|
|
HistoryView::SendActionPainter _sendActionPainter;
|
2016-12-01 19:20:33 +00:00
|
|
|
|
2022-01-14 13:41:29 +00:00
|
|
|
std::deque<ItemNotification> _notifications;
|
2019-04-18 09:04:14 +00:00
|
|
|
|
2016-03-22 09:51:20 +00:00
|
|
|
};
|
2015-09-19 09:13:21 +00:00
|
|
|
|
|
|
|
class HistoryBlock {
|
|
|
|
public:
|
2018-01-11 19:33:26 +00:00
|
|
|
using Element = HistoryView::Element;
|
2018-01-11 13:07:29 +00:00
|
|
|
|
2018-01-10 13:13:33 +00:00
|
|
|
HistoryBlock(not_null<History*> history);
|
2016-03-18 19:05:08 +00:00
|
|
|
HistoryBlock(const HistoryBlock &) = delete;
|
|
|
|
HistoryBlock &operator=(const HistoryBlock &) = delete;
|
2018-01-10 13:13:33 +00:00
|
|
|
~HistoryBlock();
|
2016-03-18 19:05:08 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
std::vector<std::unique_ptr<Element>> messages;
|
2015-09-19 09:13:21 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
void remove(not_null<Element*> view);
|
2018-01-18 13:59:22 +00:00
|
|
|
void refreshView(not_null<Element*> view);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-21 18:40:00 +00:00
|
|
|
int resizeGetHeight(int newWidth, bool resizeAllItems);
|
2017-05-12 13:53:08 +00:00
|
|
|
int y() const {
|
|
|
|
return _y;
|
|
|
|
}
|
|
|
|
void setY(int y) {
|
|
|
|
_y = y;
|
|
|
|
}
|
|
|
|
int height() const {
|
|
|
|
return _height;
|
|
|
|
}
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<History*> history() const {
|
2017-05-12 13:53:08 +00:00
|
|
|
return _history;
|
|
|
|
}
|
2016-03-15 10:37:56 +00:00
|
|
|
|
2016-06-13 18:42:25 +00:00
|
|
|
HistoryBlock *previousBlock() const {
|
2017-05-12 13:53:08 +00:00
|
|
|
Expects(_indexInHistory >= 0);
|
2016-03-21 18:40:00 +00:00
|
|
|
|
2018-01-10 13:13:33 +00:00
|
|
|
return (_indexInHistory > 0)
|
|
|
|
? _history->blocks[_indexInHistory - 1].get()
|
|
|
|
: nullptr;
|
2016-03-18 19:05:08 +00:00
|
|
|
}
|
2016-06-13 18:42:25 +00:00
|
|
|
HistoryBlock *nextBlock() const {
|
2017-05-12 13:53:08 +00:00
|
|
|
Expects(_indexInHistory >= 0);
|
2016-06-13 18:42:25 +00:00
|
|
|
|
2018-01-10 13:13:33 +00:00
|
|
|
return (_indexInHistory + 1 < _history->blocks.size())
|
|
|
|
? _history->blocks[_indexInHistory + 1].get()
|
|
|
|
: nullptr;
|
2016-06-13 18:42:25 +00:00
|
|
|
}
|
2016-03-19 18:32:17 +00:00
|
|
|
void setIndexInHistory(int index) {
|
|
|
|
_indexInHistory = index;
|
|
|
|
}
|
2016-03-21 18:40:00 +00:00
|
|
|
int indexInHistory() const {
|
2017-05-12 13:53:08 +00:00
|
|
|
Expects(_indexInHistory >= 0);
|
|
|
|
Expects(_indexInHistory < _history->blocks.size());
|
2018-01-10 13:13:33 +00:00
|
|
|
Expects(_history->blocks[_indexInHistory].get() == this);
|
2016-03-21 18:40:00 +00:00
|
|
|
|
|
|
|
return _indexInHistory;
|
|
|
|
}
|
2016-03-18 19:05:08 +00:00
|
|
|
|
|
|
|
protected:
|
2017-08-17 08:31:24 +00:00
|
|
|
const not_null<History*> _history;
|
2017-05-12 13:53:08 +00:00
|
|
|
|
|
|
|
int _y = 0;
|
|
|
|
int _height = 0;
|
|
|
|
int _indexInHistory = -1;
|
2016-03-18 19:05:08 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|