mirror of https://github.com/procxx/kepka.git
Load all archive after the main list for filters.
This commit is contained in:
parent
ad8b0387f3
commit
dc49f7e6dc
|
@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_cloud_themes.h"
|
#include "data/data_cloud_themes.h"
|
||||||
|
#include "data/data_chat_filters.h"
|
||||||
#include "data/data_histories.h"
|
#include "data/data_histories.h"
|
||||||
#include "dialogs/dialogs_key.h"
|
#include "dialogs/dialogs_key.h"
|
||||||
#include "core/core_cloud_password.h"
|
#include "core/core_cloud_password.h"
|
||||||
|
@ -248,6 +249,13 @@ ApiWrap::ApiWrap(not_null<Main::Session*> session)
|
||||||
photoUploadReady(data.fullId, data.file);
|
photoUploadReady(data.fullId, data.file);
|
||||||
}, _session->lifetime());
|
}, _session->lifetime());
|
||||||
|
|
||||||
|
_session->data().chatsFilters().changed(
|
||||||
|
) | rpl::filter([=] {
|
||||||
|
return _session->data().chatsFilters().archiveNeeded();
|
||||||
|
}) | rpl::start_with_next([=] {
|
||||||
|
requestMoreDialogsIfNeeded();
|
||||||
|
}, _session->lifetime());
|
||||||
|
|
||||||
setupSupportMode();
|
setupSupportMode();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -856,13 +864,11 @@ void ApiWrap::requestMoreDialogs(Data::Folder *folder) {
|
||||||
count);
|
count);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!folder) {
|
if (!folder
|
||||||
if (!_dialogsLoadState || !_dialogsLoadState->listReceived) {
|
&& (!_dialogsLoadState || !_dialogsLoadState->listReceived)) {
|
||||||
refreshDialogsLoadBlocked();
|
refreshDialogsLoadBlocked();
|
||||||
}
|
|
||||||
requestDialogs(folder);
|
|
||||||
requestContacts();
|
|
||||||
}
|
}
|
||||||
|
requestMoreDialogsIfNeeded();
|
||||||
_session->data().chatsListChanged(folder);
|
_session->data().chatsListChanged(folder);
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
dialogsLoadState(folder)->requestId = 0;
|
dialogsLoadState(folder)->requestId = 0;
|
||||||
|
@ -888,6 +894,21 @@ void ApiWrap::refreshDialogsLoadBlocked() {
|
||||||
&& (_dialogsLoadState->offsetDate <= _dialogsLoadTill);
|
&& (_dialogsLoadState->offsetDate <= _dialogsLoadTill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApiWrap::requestMoreDialogsIfNeeded() {
|
||||||
|
if (_dialogsLoadState && !_dialogsLoadState->listReceived) {
|
||||||
|
if (_dialogsLoadState->requestId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
requestDialogs(nullptr);
|
||||||
|
} else if (const auto folder = _session->data().folderLoaded(
|
||||||
|
Data::Folder::kId)) {
|
||||||
|
if (_session->data().chatsFilters().archiveNeeded()) {
|
||||||
|
requestMoreDialogs(folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
requestContacts();
|
||||||
|
}
|
||||||
|
|
||||||
void ApiWrap::updateDialogsOffset(
|
void ApiWrap::updateDialogsOffset(
|
||||||
Data::Folder *folder,
|
Data::Folder *folder,
|
||||||
const QVector<MTPDialog> &dialogs,
|
const QVector<MTPDialog> &dialogs,
|
||||||
|
|
|
@ -170,6 +170,7 @@ public:
|
||||||
void requestDialogs(Data::Folder *folder = nullptr);
|
void requestDialogs(Data::Folder *folder = nullptr);
|
||||||
void requestPinnedDialogs(Data::Folder *folder = nullptr);
|
void requestPinnedDialogs(Data::Folder *folder = nullptr);
|
||||||
void requestMoreBlockedByDateDialogs();
|
void requestMoreBlockedByDateDialogs();
|
||||||
|
void requestMoreDialogsIfNeeded();
|
||||||
rpl::producer<bool> dialogsLoadMayBlockByDate() const;
|
rpl::producer<bool> dialogsLoadMayBlockByDate() const;
|
||||||
rpl::producer<bool> dialogsLoadBlockedByDate() const;
|
rpl::producer<bool> dialogsLoadBlockedByDate() const;
|
||||||
|
|
||||||
|
|
|
@ -439,6 +439,15 @@ const ChatFilter &ChatFilters::applyUpdatedPinned(
|
||||||
return *i;
|
return *i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChatFilters::archiveNeeded() const {
|
||||||
|
for (const auto &filter : _list) {
|
||||||
|
if (!(filter.flags() & ChatFilter::Flag::NoArchived)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<ChatFilter> &ChatFilters::list() const {
|
const std::vector<ChatFilter> &ChatFilters::list() const {
|
||||||
return _list;
|
return _list;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,8 @@ public:
|
||||||
FilterId id,
|
FilterId id,
|
||||||
const std::vector<Dialogs::Key> &dialogs);
|
const std::vector<Dialogs::Key> &dialogs);
|
||||||
|
|
||||||
|
[[nodiscard]] bool archiveNeeded() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void load(bool force);
|
void load(bool force);
|
||||||
bool applyOrder(const QVector<MTPint> &order);
|
bool applyOrder(const QVector<MTPint> &order);
|
||||||
|
|
Loading…
Reference in New Issue