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"
|
2022-10-13 10:32:03 +00:00
|
|
|
#include "data/data_thread.h"
|
2020-09-29 08:36:30 +00:00
|
|
|
#include "history/view/history_view_send_action.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;
|
2023-01-26 15:36:43 +00:00
|
|
|
class HistoryTranslation;
|
2018-01-30 12:32:00 +00:00
|
|
|
class HistoryItem;
|
2021-10-02 11:28:21 +00:00
|
|
|
struct HistoryMessageMarkupData;
|
2022-01-04 21:11:29 +00:00
|
|
|
class HistoryMainElementDelegateMixin;
|
2023-01-26 15:36:43 +00:00
|
|
|
struct LanguageId;
|
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;
|
2022-11-05 12:41:27 +00:00
|
|
|
class SponsoredMessages;
|
2021-08-31 16:47:38 +00:00
|
|
|
|
|
|
|
enum class ForwardOptions {
|
|
|
|
PreserveInfo,
|
|
|
|
NoSenderNames,
|
|
|
|
NoNamesAndCaptions,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ForwardDraft {
|
|
|
|
MessageIdsList ids;
|
|
|
|
ForwardOptions options = ForwardOptions::PreserveInfo;
|
2022-11-01 04:46:31 +00:00
|
|
|
|
2022-11-01 08:29:12 +00:00
|
|
|
friend inline auto operator<=>(
|
2022-11-01 04:46:31 +00:00
|
|
|
const ForwardDraft&,
|
|
|
|
const ForwardDraft&) = default;
|
2021-08-31 16:47:38 +00:00
|
|
|
};
|
|
|
|
|
2022-11-01 04:46:31 +00:00
|
|
|
using ForwardDrafts = base::flat_map<MsgId, ForwardDraft>;
|
|
|
|
|
2021-08-31 16:47:38 +00:00
|
|
|
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-10-13 10:32:03 +00:00
|
|
|
class History final : public Data::Thread {
|
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);
|
2019-04-16 08:50:59 +00:00
|
|
|
~History();
|
2016-03-22 09:51:20 +00:00
|
|
|
|
2022-10-13 10:32:03 +00:00
|
|
|
not_null<History*> owningHistory() override {
|
|
|
|
return this;
|
|
|
|
}
|
2022-10-17 16:29:48 +00:00
|
|
|
[[nodiscard]] Data::Thread *threadFor(MsgId topicRootId);
|
|
|
|
[[nodiscard]] const Data::Thread *threadFor(MsgId topicRootId) const;
|
2022-10-13 10:32:03 +00:00
|
|
|
|
2022-01-04 21:11:29 +00:00
|
|
|
[[nodiscard]] auto delegateMixin() const
|
|
|
|
-> not_null<HistoryMainElementDelegateMixin*> {
|
|
|
|
return _delegateMixin.get();
|
|
|
|
}
|
|
|
|
|
2022-10-19 13:55:33 +00:00
|
|
|
void forumChanged(Data::Forum *old);
|
2022-12-02 14:19:56 +00:00
|
|
|
[[nodiscard]] bool isForum() const;
|
2022-10-19 13:55:33 +00:00
|
|
|
|
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;
|
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>
|
2022-12-14 12:15:46 +00:00
|
|
|
not_null<HistoryItem*> makeMessage(Args &&...args) {
|
|
|
|
return static_cast<HistoryItem*>(
|
2020-02-20 08:45:25 +00:00
|
|
|
insertItem(
|
2022-12-14 12:15:46 +00:00
|
|
|
std::make_unique<HistoryItem>(
|
2020-02-20 08:45:25 +00:00
|
|
|
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);
|
2022-10-13 17:34:04 +00:00
|
|
|
void destroyMessagesByTopic(MsgId topicRootId);
|
2020-02-20 08:45:25 +00:00
|
|
|
|
2022-10-28 05:19:27 +00:00
|
|
|
void unpinMessagesFor(MsgId topicRootId);
|
2020-10-30 14:12:04 +00:00
|
|
|
|
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,
|
2022-11-01 04:46:31 +00:00
|
|
|
not_null<HistoryItem*> forwardOriginal,
|
|
|
|
MsgId topicRootId);
|
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]] 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
|
|
|
|
2022-10-17 16:29:48 +00:00
|
|
|
[[nodiscard]] bool isServerSideUnread(
|
|
|
|
not_null<const HistoryItem*> item) const override;
|
|
|
|
|
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);
|
2022-10-20 08:57:12 +00:00
|
|
|
void setUnreadMark(bool unread);
|
2020-03-20 15:19:55 +00:00
|
|
|
void setFakeUnreadWhileOpened(bool enabled);
|
|
|
|
[[nodiscard]] bool fakeUnreadWhileOpened() const;
|
2022-10-13 10:32:03 +00:00
|
|
|
void setMuted(bool muted) override;
|
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
|
|
|
|
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
|
|
|
|
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()
|
2022-10-17 16:29:48 +00:00
|
|
|
-> not_null<HistoryView::SendActionPainter*> override {
|
2020-09-29 08:36:30 +00:00
|
|
|
return &_sendActionPainter;
|
|
|
|
}
|
2017-12-07 14:27:59 +00:00
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
void clearLastKeyboard();
|
2022-10-07 13:56:07 +00:00
|
|
|
void clearUnreadMentionsFor(MsgId topicRootId);
|
2022-10-08 11:14:38 +00:00
|
|
|
void clearUnreadReactionsFor(MsgId topicRootId);
|
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);
|
|
|
|
|
2022-10-17 16:29:48 +00:00
|
|
|
Data::Draft *localDraft(MsgId topicRootId) const {
|
|
|
|
return draft(Data::DraftKey::Local(topicRootId));
|
2020-11-13 17:27:08 +00:00
|
|
|
}
|
2022-10-17 16:29:48 +00:00
|
|
|
Data::Draft *localEditDraft(MsgId topicRootId) const {
|
|
|
|
return draft(Data::DraftKey::LocalEdit(topicRootId));
|
2016-06-03 18:24:27 +00:00
|
|
|
}
|
2022-10-17 16:29:48 +00:00
|
|
|
Data::Draft *cloudDraft(MsgId topicRootId) const {
|
|
|
|
return draft(Data::DraftKey::Cloud(topicRootId));
|
2020-11-13 17:27:08 +00:00
|
|
|
}
|
|
|
|
void setLocalDraft(std::unique_ptr<Data::Draft> &&draft) {
|
2022-10-17 16:29:48 +00:00
|
|
|
setDraft(
|
|
|
|
Data::DraftKey::Local(draft->topicRootId),
|
|
|
|
std::move(draft));
|
2020-11-13 17:27:08 +00:00
|
|
|
}
|
|
|
|
void setLocalEditDraft(std::unique_ptr<Data::Draft> &&draft) {
|
2022-10-17 16:29:48 +00:00
|
|
|
setDraft(
|
|
|
|
Data::DraftKey::LocalEdit(draft->topicRootId),
|
|
|
|
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) {
|
2022-10-17 16:29:48 +00:00
|
|
|
setDraft(
|
|
|
|
Data::DraftKey::Cloud(draft->topicRootId),
|
|
|
|
std::move(draft));
|
2016-04-08 14:16:52 +00:00
|
|
|
}
|
2022-10-17 16:29:48 +00:00
|
|
|
void clearLocalDraft(MsgId topicRootId) {
|
|
|
|
clearDraft(Data::DraftKey::Local(topicRootId));
|
2020-11-13 17:27:08 +00:00
|
|
|
}
|
2022-10-17 16:29:48 +00:00
|
|
|
void clearCloudDraft(MsgId topicRootId) {
|
|
|
|
clearDraft(Data::DraftKey::Cloud(topicRootId));
|
2020-11-13 17:27:08 +00:00
|
|
|
}
|
2022-10-17 16:29:48 +00:00
|
|
|
void clearLocalEditDraft(MsgId topicRootId) {
|
|
|
|
clearDraft(Data::DraftKey::LocalEdit(topicRootId));
|
2020-11-13 17:27:08 +00:00
|
|
|
}
|
|
|
|
void clearDrafts();
|
2022-10-17 16:29:48 +00:00
|
|
|
Data::Draft *createCloudDraft(
|
|
|
|
MsgId topicRootId,
|
|
|
|
const Data::Draft *fromDraft);
|
|
|
|
[[nodiscard]] bool skipCloudDraftUpdate(
|
|
|
|
MsgId topicRootId,
|
|
|
|
TimeId date) const;
|
|
|
|
void startSavingCloudDraft(MsgId topicRootId);
|
|
|
|
void finishSavingCloudDraft(MsgId topicRootId, TimeId savedAt);
|
2020-11-13 17:27:08 +00:00
|
|
|
void takeLocalDraft(not_null<History*> from);
|
2022-10-17 16:29:48 +00:00
|
|
|
void applyCloudDraft(MsgId topicRootId);
|
|
|
|
void draftSavedToCloud(MsgId topicRootId);
|
2016-02-25 10:32:31 +00:00
|
|
|
|
2022-11-01 04:46:31 +00:00
|
|
|
[[nodiscard]] const Data::ForwardDraft &forwardDraft(
|
|
|
|
MsgId topicRootId) const;
|
2021-08-31 16:47:38 +00:00
|
|
|
[[nodiscard]] Data::ResolvedForwardDraft resolveForwardDraft(
|
|
|
|
const Data::ForwardDraft &draft) const;
|
2022-11-01 04:46:31 +00:00
|
|
|
[[nodiscard]] Data::ResolvedForwardDraft resolveForwardDraft(
|
|
|
|
MsgId topicRootId);
|
|
|
|
void setForwardDraft(MsgId topicRootId, 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;
|
2019-04-22 14:22:39 +00:00
|
|
|
Dialogs::UnreadState chatListUnreadState() const override;
|
2022-10-20 08:57:12 +00:00
|
|
|
Dialogs::BadgesState chatListBadgesState() 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;
|
2023-02-09 05:56:47 +00:00
|
|
|
void chatListPreloadData() override;
|
2018-01-05 15:57:18 +00:00
|
|
|
void paintUserpic(
|
|
|
|
Painter &p,
|
2022-12-05 12:18:10 +00:00
|
|
|
Ui::PeerUserpicView &view,
|
2022-09-29 10:33:17 +00:00
|
|
|
const Dialogs::Ui::PaintContext &context) const override;
|
2018-01-05 15:57:18 +00:00
|
|
|
|
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;
|
|
|
|
|
2022-10-13 10:32:03 +00:00
|
|
|
[[nodiscard]] bool isTopPromoted() const;
|
|
|
|
|
2023-01-26 15:36:43 +00:00
|
|
|
void translateOfferFrom(LanguageId id);
|
|
|
|
[[nodiscard]] LanguageId translateOfferedFrom() const;
|
|
|
|
void translateTo(LanguageId id);
|
|
|
|
[[nodiscard]] LanguageId translatedTo() const;
|
|
|
|
|
|
|
|
[[nodiscard]] HistoryTranslation *translation() const;
|
|
|
|
|
2022-10-13 10:32:03 +00:00
|
|
|
const not_null<PeerData*> peer;
|
|
|
|
|
2018-01-21 19:21:08 +00:00
|
|
|
// Still public data.
|
|
|
|
std::deque<std::unique_ptr<HistoryBlock>> blocks;
|
|
|
|
|
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
|
|
|
|
2018-01-31 17:10:29 +00:00
|
|
|
private:
|
|
|
|
friend class HistoryBlock;
|
|
|
|
|
2022-07-04 06:14:24 +00:00
|
|
|
enum class Flag : uchar {
|
2022-01-26 16:01:40 +00:00
|
|
|
HasPendingResizedItems = (1 << 0),
|
2022-12-02 14:19:56 +00:00
|
|
|
PendingAllItemsResize = (1 << 1),
|
|
|
|
IsTopPromoted = (1 << 2),
|
|
|
|
IsForum = (1 << 3),
|
|
|
|
FakeUnreadWhileOpened = (1 << 4),
|
|
|
|
HasPinnedMessages = (1 << 5),
|
2023-02-09 05:56:47 +00:00
|
|
|
ResolveChatListMessage = (1 << 6),
|
2018-01-31 17:10:29 +00:00
|
|
|
};
|
|
|
|
using Flags = base::flags<Flag>;
|
|
|
|
friend inline constexpr auto is_flag_type(Flag) {
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2022-10-13 10:32:03 +00:00
|
|
|
void cacheTopPromoted(bool promoted);
|
|
|
|
|
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);
|
2022-11-05 12:41:27 +00:00
|
|
|
|
|
|
|
friend class Data::SponsoredMessages;
|
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-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();
|
2023-02-09 05:56:47 +00:00
|
|
|
void allowChatListMessageResolve();
|
|
|
|
void resolveChatListMessageGroup();
|
2019-01-15 11:57:45 +00:00
|
|
|
|
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);
|
|
|
|
|
2022-10-17 16:29:48 +00:00
|
|
|
void createLocalDraftFromCloud(MsgId topicRootId);
|
2019-03-12 12:54:15 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
HistoryItem *insertJoinedMessage();
|
2021-11-08 05:41:50 +00:00
|
|
|
void insertMessageToBlocks(not_null<HistoryItem*> item);
|
2019-07-17 12:41:48 +00:00
|
|
|
|
2022-10-20 08:57:12 +00:00
|
|
|
[[nodiscard]] Dialogs::BadgesState computeBadgesState() const;
|
|
|
|
[[nodiscard]] Dialogs::BadgesState adjustBadgesStateByFolder(
|
|
|
|
Dialogs::BadgesState state) const;
|
2022-10-19 13:55:33 +00:00
|
|
|
[[nodiscard]] Dialogs::UnreadState computeUnreadState() const;
|
2019-04-16 08:50:59 +00:00
|
|
|
void setFolderPointer(Data::Folder *folder);
|
|
|
|
|
2022-08-09 11:12:19 +00:00
|
|
|
int chatListNameVersion() const override;
|
|
|
|
|
2022-10-20 08:57:12 +00:00
|
|
|
void hasUnreadMentionChanged(bool has) override;
|
|
|
|
void hasUnreadReactionChanged(bool has) override;
|
|
|
|
|
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;
|
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;
|
2022-12-14 12:15:46 +00:00
|
|
|
HistoryItem *_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;
|
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;
|
|
|
|
|
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;
|
2023-01-26 15:36:43 +00:00
|
|
|
std::unique_ptr<HistoryTranslation> _translation;
|
2015-09-19 09:13:21 +00:00
|
|
|
|
2020-11-13 17:27:08 +00:00
|
|
|
Data::HistoryDrafts _drafts;
|
2022-10-17 16:29:48 +00:00
|
|
|
base::flat_map<MsgId, TimeId> _acceptCloudDraftsAfter;
|
|
|
|
base::flat_map<MsgId, int> _savingCloudDraftRequests;
|
2022-11-01 04:46:31 +00:00
|
|
|
Data::ForwardDrafts _forwardDrafts;
|
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
|
|
|
|
2023-01-26 15:36:43 +00:00
|
|
|
|
2022-12-02 14:19:56 +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
|
|
|
|
2022-12-02 14:19:56 +00:00
|
|
|
enum class ResizeRequest {
|
|
|
|
ReinitAll = 0,
|
|
|
|
ResizeAll = 1,
|
|
|
|
ResizePending = 2,
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2022-12-02 14:19:56 +00:00
|
|
|
int resizeGetHeight(int newWidth, ResizeRequest request);
|
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
|
|
|
};
|