Store directly pending_order in Dialog.
This commit is contained in:
parent
97eb982ade
commit
0bbd41a5d5
@ -14899,10 +14899,7 @@ void MessagesManager::set_dialog_last_message_id(Dialog *d, MessageId last_messa
|
||||
d->is_last_message_deleted_locally = false;
|
||||
on_dialog_updated(d->dialog_id, "update_delete_last_message_date");
|
||||
}
|
||||
if (d->pending_last_message_date != 0) {
|
||||
d->pending_last_message_date = 0;
|
||||
d->pending_last_message_id = MessageId();
|
||||
}
|
||||
d->pending_order = DEFAULT_ORDER;
|
||||
}
|
||||
|
||||
void MessagesManager::set_dialog_first_database_message_id(Dialog *d, MessageId first_database_message_id,
|
||||
@ -15106,10 +15103,7 @@ void MessagesManager::set_dialog_is_empty(Dialog *d, const char *source) {
|
||||
|
||||
on_dialog_updated(d->dialog_id, "set_dialog_is_empty");
|
||||
}
|
||||
if (d->pending_last_message_date != 0) {
|
||||
d->pending_last_message_date = 0;
|
||||
d->pending_last_message_id = MessageId();
|
||||
}
|
||||
d->pending_order = DEFAULT_ORDER;
|
||||
if (d->last_database_message_id.is_valid()) {
|
||||
set_dialog_first_database_message_id(d, MessageId(), "set_dialog_is_empty");
|
||||
set_dialog_last_database_message_id(d, MessageId(), "set_dialog_is_empty");
|
||||
@ -36940,24 +36934,21 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr<Message> &&last_datab
|
||||
}
|
||||
};
|
||||
|
||||
auto last_message_date = last_database_message->date;
|
||||
auto pending_order = get_dialog_order(last_message_id, last_database_message->date);
|
||||
if (dependent_dialog_count == 0) {
|
||||
if (!add_dialog_last_database_message(d, std::move(last_database_message))) {
|
||||
// failed to add last message; keep the current position and get history from the database
|
||||
d->pending_last_message_date = last_message_date;
|
||||
d->pending_last_message_id = last_message_id;
|
||||
d->pending_order = pending_order;
|
||||
}
|
||||
} else {
|
||||
// can't add message immediately, because need to notify first about adding of dependent dialogs
|
||||
d->pending_last_message_date = last_message_date;
|
||||
d->pending_last_message_id = last_message_id;
|
||||
d->pending_order = pending_order;
|
||||
pending_add_dialog_data_[dialog_id] = {dependent_dialog_count, std::move(last_database_message)};
|
||||
}
|
||||
} else if (last_database_message_id.is_valid()) {
|
||||
auto date = DialogDate(order, dialog_id).get_date();
|
||||
if (date < MIN_PINNED_DIALOG_DATE) {
|
||||
d->pending_last_message_date = date;
|
||||
d->pending_last_message_id = last_message_id;
|
||||
d->pending_order = get_dialog_order(last_message_id, date);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37128,9 +37119,8 @@ bool MessagesManager::add_dialog_last_database_message(Dialog *d, unique_ptr<Mes
|
||||
set_dialog_last_message_id(d, m->message_id, "add_dialog_last_database_message 2", m);
|
||||
send_update_chat_last_message(d, "add_dialog_last_database_message 3");
|
||||
} else {
|
||||
if (d->pending_last_message_date != 0) {
|
||||
d->pending_last_message_date = 0;
|
||||
d->pending_last_message_id = MessageId();
|
||||
if (d->pending_order != DEFAULT_ORDER) {
|
||||
d->pending_order = DEFAULT_ORDER;
|
||||
need_update_dialog_pos = true;
|
||||
}
|
||||
on_dialog_updated(dialog_id, "add_dialog_last_database_message 4"); // resave without last database message
|
||||
@ -37305,11 +37295,10 @@ void MessagesManager::update_dialog_pos(Dialog *d, const char *source, bool need
|
||||
new_order = clear_order;
|
||||
}
|
||||
}
|
||||
if (d->pending_last_message_date > 0) {
|
||||
LOG(INFO) << "Pending last " << d->pending_last_message_id << " at " << d->pending_last_message_date << " found";
|
||||
int64 pending_order = get_dialog_order(d->pending_last_message_id, d->pending_last_message_date);
|
||||
if (pending_order > new_order) {
|
||||
new_order = pending_order;
|
||||
if (d->pending_order != DEFAULT_ORDER) {
|
||||
LOG(INFO) << "Pending order " << d->pending_order << " found";
|
||||
if (d->pending_order > new_order) {
|
||||
new_order = d->pending_order;
|
||||
}
|
||||
}
|
||||
if (d->draft_message != nullptr && !need_hide_dialog_draft_message(d->dialog_id)) {
|
||||
|
@ -1344,13 +1344,12 @@ class MessagesManager final : public Actor {
|
||||
MessageId
|
||||
max_unavailable_message_id; // maximum unavailable message identifier for dialogs with cleared/unavailable history
|
||||
|
||||
int32 last_clear_history_date = 0;
|
||||
MessageId last_clear_history_message_id;
|
||||
int64 order = DEFAULT_ORDER;
|
||||
int64 pending_order = DEFAULT_ORDER;
|
||||
MessageId deleted_last_message_id;
|
||||
int32 delete_last_message_date = 0;
|
||||
int32 pending_last_message_date = 0;
|
||||
MessageId pending_last_message_id;
|
||||
int32 last_clear_history_date = 0;
|
||||
MessageId last_clear_history_message_id;
|
||||
MessageId last_edited_message_id;
|
||||
uint32 scheduled_messages_sync_generation = 0;
|
||||
uint32 last_repair_scheduled_messages_generation = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user