2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Some internal HistoryItem refactoring.

Replace most IsServerMsgId / id <=> 0 with isRegular().
Track isLocal / isHistoryEntry in flags.
Remove toHistoryMessage.
This commit is contained in:
John Preston
2021-11-07 12:06:00 +04:00
parent 22b37c4bf8
commit c534f3f22e
52 changed files with 460 additions and 524 deletions

View File

@@ -36,7 +36,7 @@ void SendBotCallbackData(
int column,
std::optional<MTPInputCheckPasswordSRP> password = std::nullopt,
Fn<void(const MTP::Error &)> handleError = nullptr) {
if (!IsServerMsgId(item->id)) {
if (!item->isRegular()) {
return;
}
const auto history = item->history();
@@ -150,7 +150,7 @@ void SendBotCallbackDataWithPassword(
not_null<HistoryItem*> item,
int row,
int column) {
if (!IsServerMsgId(item->id)) {
if (!item->isRegular()) {
return;
}
const auto history = item->history();

View File

@@ -182,8 +182,7 @@ void Polls::close(not_null<HistoryItem*> item) {
void Polls::reloadResults(not_null<HistoryItem*> item) {
const auto itemId = item->fullId();
if (!IsServerMsgId(item->id)
|| _pollReloadRequestIds.contains(itemId)) {
if (!item->isRegular() || _pollReloadRequestIds.contains(itemId)) {
return;
}
const auto requestId = _api.request(MTPmessages_GetPollResults(

View File

@@ -111,8 +111,6 @@ void SendExistingMedia(
if (message.action.options.scheduled) {
flags |= MessageFlag::IsOrWasScheduled;
sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_date;
} else {
flags |= MessageFlag::LocalHistoryEntry;
}
session->data().registerMessageRandomId(randomId, newId);
@@ -271,8 +269,6 @@ bool SendDice(Api::MessageToSend &message) {
if (message.action.options.scheduled) {
flags |= MessageFlag::IsOrWasScheduled;
sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_date;
} else {
flags |= MessageFlag::LocalHistoryEntry;
}
session->data().registerMessageRandomId(randomId, newId);
@@ -387,8 +383,6 @@ void SendConfirmedFile(
// Scheduled messages have no the 'edited' badge.
flags |= MessageFlag::HideEdited;
} else {
flags |= MessageFlag::LocalHistoryEntry;
}
if (file->type == SendMediaType::Audio) {
if (!peer->isChannel() || peer->isMegagroup()) {