parent
1bc438ed01
commit
1833fac094
|
@ -113,12 +113,9 @@ HistoryItemsList::const_iterator Groups::findPositionForItem(
|
|||
const HistoryItemsList &group,
|
||||
not_null<HistoryItem*> item) {
|
||||
const auto last = end(group);
|
||||
if (!item->isRegular()) {
|
||||
return last;
|
||||
}
|
||||
const auto itemId = item->id;
|
||||
for (auto result = begin(group); result != last; ++result) {
|
||||
if ((*result)->isRegular() && (*result)->id > itemId) {
|
||||
if ((*result)->id > itemId) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ Q_DECLARE_METATYPE(MsgId);
|
|||
constexpr auto StartClientMsgId = MsgId(0x01 - (1LL << 58));
|
||||
constexpr auto EndClientMsgId = MsgId(-(1LL << 57));
|
||||
constexpr auto ServerMaxMsgId = MsgId(1LL << 56);
|
||||
constexpr auto ScheduledMsgIdsRange = (1LL << 32);
|
||||
constexpr auto ShowAtUnreadMsgId = MsgId(0);
|
||||
|
||||
constexpr auto SpecialMsgIdShift = EndClientMsgId.bare;
|
||||
|
|
|
@ -319,7 +319,7 @@ void ScheduledMessages::apply(
|
|||
} else {
|
||||
Assert(!list.itemById.contains(local->id));
|
||||
Assert(!list.idByItem.contains(local));
|
||||
local->setRealId(local->history()->nextNonHistoryEntryId());
|
||||
local->setRealId(local->history()->scheduledMessageId(id));
|
||||
list.idByItem.emplace(local, id);
|
||||
list.itemById.emplace(id, local);
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ HistoryItem *ScheduledMessages::append(
|
|||
}
|
||||
|
||||
const auto item = _session->data().addNewMessage(
|
||||
history->nextNonHistoryEntryId(),
|
||||
history->scheduledMessageId(id),
|
||||
PrepareMessage(message),
|
||||
MessageFlags(), // localFlags
|
||||
NewMessageType::Existing);
|
||||
|
|
|
@ -993,7 +993,7 @@ private:
|
|||
std::unique_ptr<SponsoredMessages> _sponsoredMessages;
|
||||
const std::unique_ptr<Reactions> _reactions;
|
||||
|
||||
MsgId _nonHistoryEntryId = ServerMaxMsgId;
|
||||
MsgId _nonHistoryEntryId = ServerMaxMsgId.bare + ScheduledMsgIdsRange;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
|
|
|
@ -1760,6 +1760,10 @@ MsgId History::nextNonHistoryEntryId() {
|
|||
return owner().nextNonHistoryEntryId();
|
||||
}
|
||||
|
||||
MsgId History::scheduledMessageId(MsgId remoteScheduledMsgId) const {
|
||||
return ServerMaxMsgId + remoteScheduledMsgId + 1;
|
||||
}
|
||||
|
||||
bool History::folderKnown() const {
|
||||
return _folder.has_value();
|
||||
}
|
||||
|
|
|
@ -439,6 +439,7 @@ public:
|
|||
[[nodiscard]] std::pair<Element*, int> findItemAndOffset(int top) const;
|
||||
|
||||
[[nodiscard]] MsgId nextNonHistoryEntryId();
|
||||
[[nodiscard]] MsgId scheduledMessageId(MsgId remoteScheduledMsgId) const;
|
||||
|
||||
bool folderKnown() const override;
|
||||
Data::Folder *folder() const override;
|
||||
|
|
Loading…
Reference in New Issue