mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Fixed glitch for scheduled messages with elapsed date in channels.
This commit is contained in:
parent
7de9bcad03
commit
5540b0bb8b
2 changed files with 24 additions and 18 deletions
|
@ -63,6 +63,22 @@ enum class DataIsLoadedResult {
|
||||||
Ok = 3,
|
Ok = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void ProcessScheduledMessageWithElapsedTime(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
bool needToAdd,
|
||||||
|
const MTPDmessage &data) {
|
||||||
|
if (needToAdd && !data.is_from_scheduled()) {
|
||||||
|
// If we still need to add a new message,
|
||||||
|
// we should first check if this message is in
|
||||||
|
// the list of scheduled messages.
|
||||||
|
// This is necessary to correctly update the file reference.
|
||||||
|
// Note that when a message is scheduled until online
|
||||||
|
// while the recipient is already online, the server sends
|
||||||
|
// an ordinary new message with skipped "from_scheduled" flag.
|
||||||
|
session->data().scheduledMessages().checkEntitiesAndUpdate(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool IsForceLogoutNotification(const MTPDupdateServiceNotification &data) {
|
bool IsForceLogoutNotification(const MTPDupdateServiceNotification &data) {
|
||||||
return qs(data.vtype()).startsWith(qstr("AUTH_KEY_DROP_"));
|
return qs(data.vtype()).startsWith(qstr("AUTH_KEY_DROP_"));
|
||||||
}
|
}
|
||||||
|
@ -958,17 +974,7 @@ void Updates::applyUpdateNoPtsCheck(const MTPUpdate &update) {
|
||||||
LOG(("Skipping message, because it is already in blocks!"));
|
LOG(("Skipping message, because it is already in blocks!"));
|
||||||
needToAdd = false;
|
needToAdd = false;
|
||||||
}
|
}
|
||||||
if (needToAdd && !data.is_from_scheduled()) {
|
ProcessScheduledMessageWithElapsedTime(_session, needToAdd, data);
|
||||||
// If we still need to add a new message,
|
|
||||||
// we should first check if this message is in
|
|
||||||
// the list of scheduled messages.
|
|
||||||
// This is necessary to correctly update the file reference.
|
|
||||||
// Note that when a message is scheduled until online
|
|
||||||
// while the recipient is already online, the server sends
|
|
||||||
// an ordinary new message with skipped "from_scheduled" flag.
|
|
||||||
_session->data().scheduledMessages().checkEntitiesAndUpdate(
|
|
||||||
data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (needToAdd) {
|
if (needToAdd) {
|
||||||
_session->data().addNewMessage(
|
_session->data().addNewMessage(
|
||||||
|
@ -1057,10 +1063,12 @@ void Updates::applyUpdateNoPtsCheck(const MTPUpdate &update) {
|
||||||
auto &d = update.c_updateNewChannelMessage();
|
auto &d = update.c_updateNewChannelMessage();
|
||||||
auto needToAdd = true;
|
auto needToAdd = true;
|
||||||
if (d.vmessage().type() == mtpc_message) { // index forwarded messages to links _overview
|
if (d.vmessage().type() == mtpc_message) { // index forwarded messages to links _overview
|
||||||
if (_session->data().checkEntitiesAndViewsUpdate(d.vmessage().c_message())) { // already in blocks
|
const auto &data = d.vmessage().c_message();
|
||||||
|
if (_session->data().checkEntitiesAndViewsUpdate(data)) { // already in blocks
|
||||||
LOG(("Skipping message, because it is already in blocks!"));
|
LOG(("Skipping message, because it is already in blocks!"));
|
||||||
needToAdd = false;
|
needToAdd = false;
|
||||||
}
|
}
|
||||||
|
ProcessScheduledMessageWithElapsedTime(_session, needToAdd, data);
|
||||||
}
|
}
|
||||||
if (needToAdd) {
|
if (needToAdd) {
|
||||||
_session->data().addNewMessage(
|
_session->data().addNewMessage(
|
||||||
|
|
|
@ -228,14 +228,12 @@ void ScheduledMessages::apply(const MTPDupdateNewScheduledMessage &update) {
|
||||||
|
|
||||||
void ScheduledMessages::checkEntitiesAndUpdate(const MTPDmessage &data) {
|
void ScheduledMessages::checkEntitiesAndUpdate(const MTPDmessage &data) {
|
||||||
// When the user sends a message with a media scheduled until online
|
// When the user sends a message with a media scheduled until online
|
||||||
// while the recipient is already online, the server sends
|
// while the recipient is already online, or scheduled message
|
||||||
// updateNewMessage to the client and the client calls this method.
|
// is already due and is sent immediately, the server sends
|
||||||
|
// updateNewMessage or updateNewChannelMessage to the client
|
||||||
|
// and the client calls this method.
|
||||||
|
|
||||||
const auto peer = peerFromMTP(data.vpeer_id());
|
const auto peer = peerFromMTP(data.vpeer_id());
|
||||||
if (!peerIsUser(peer)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto history = _session->data().historyLoaded(peer);
|
const auto history = _session->data().historyLoaded(peer);
|
||||||
if (!history) {
|
if (!history) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue