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