Add get_dialog_public_order overload from DialogList.

GitOrigin-RevId: 9ac90c9f041a756b4adbd1c9e632f97cf43edf66
This commit is contained in:
levlam 2020-04-13 04:48:21 +03:00
parent 65cd8e00a2
commit 65c6ac69eb
2 changed files with 13 additions and 4 deletions

View File

@ -13123,7 +13123,7 @@ vector<DialogId> MessagesManager::get_dialogs(FolderId folder_id, DialogDate off
auto d = get_dialog(sponsored_dialog_id_); auto d = get_dialog(sponsored_dialog_id_);
CHECK(d != nullptr); CHECK(d != nullptr);
if (is_dialog_sponsored(d)) { if (is_dialog_sponsored(d)) {
DialogDate date(get_dialog_public_order(folder_id, d), d->dialog_id); DialogDate date(get_dialog_public_order(&list, d), d->dialog_id);
if (offset < date) { if (offset < date) {
result.push_back(sponsored_dialog_id_); result.push_back(sponsored_dialog_id_);
offset = date; offset = date;
@ -28238,10 +28238,17 @@ bool MessagesManager::is_dialog_sponsored(const Dialog *d) const {
} }
int64 MessagesManager::get_dialog_public_order(FolderId folder_id, const Dialog *d) const { int64 MessagesManager::get_dialog_public_order(FolderId folder_id, const Dialog *d) const {
auto order = is_dialog_sponsored(d) && folder_id == FolderId::main() ? SPONSORED_DIALOG_ORDER : d->order; return get_dialog_public_order(get_dialog_list(folder_id), d);
}
int64 MessagesManager::get_dialog_public_order(const DialogList *list, const Dialog *d) const {
if (list == nullptr) {
return 0;
}
auto order = is_dialog_sponsored(d) && list->folder_id == FolderId::main() ? SPONSORED_DIALOG_ORDER : d->order;
DialogDate dialog_date(order, d->dialog_id); DialogDate dialog_date(order, d->dialog_id);
auto *list = get_dialog_list(folder_id); return dialog_date <= list->last_dialog_date_ ? order : 0;
return list != nullptr && dialog_date <= list->last_dialog_date_ ? order : 0;
} }
int64 MessagesManager::get_dialog_order_object(const Dialog *d) const { int64 MessagesManager::get_dialog_order_object(const Dialog *d) const {

View File

@ -2266,6 +2266,8 @@ class MessagesManager : public Actor {
int64 get_dialog_public_order(FolderId folder_id, const Dialog *d) const; int64 get_dialog_public_order(FolderId folder_id, const Dialog *d) const;
int64 get_dialog_public_order(const DialogList *list, const Dialog *d) const;
int64 get_dialog_order_object(const Dialog *d) const; int64 get_dialog_order_object(const Dialog *d) const;
bool update_dialog_draft_message(Dialog *d, unique_ptr<DraftMessage> &&draft_message, bool from_update, bool update_dialog_draft_message(Dialog *d, unique_ptr<DraftMessage> &&draft_message, bool from_update,