Compare commits

..

No commits in common. "dev" and "v5.16.4" have entirely different histories.
dev ... v5.16.4

6 changed files with 22 additions and 80 deletions

View file

@ -15,10 +15,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h" #include "history/history_item.h"
#include "main/main_session.h" #include "main/main_session.h"
// AyuGram includes
#include "ayu/ayu_settings.h"
namespace Api { namespace Api {
namespace { namespace {
@ -87,8 +83,6 @@ void ViewsManager::pollExtendedMedia(
} }
void ViewsManager::viewsIncrement() { void ViewsManager::viewsIncrement() {
const auto &settings = AyuSettings::getInstance();
for (auto i = _toIncrement.begin(); i != _toIncrement.cend();) { for (auto i = _toIncrement.begin(); i != _toIncrement.cend();) {
if (_incrementRequests.contains(i->first)) { if (_incrementRequests.contains(i->first)) {
++i; ++i;
@ -103,7 +97,7 @@ void ViewsManager::viewsIncrement() {
const auto requestId = _api.request(MTPmessages_GetMessagesViews( const auto requestId = _api.request(MTPmessages_GetMessagesViews(
i->first->input, i->first->input,
MTP_vector<MTPint>(ids), MTP_vector<MTPint>(ids),
MTP_bool(settings.sendReadMessages) MTP_bool(true)
)).done([=]( )).done([=](
const MTPmessages_MessageViews &result, const MTPmessages_MessageViews &result,
mtpRequestId requestId) { mtpRequestId requestId) {

View file

@ -213,11 +213,12 @@ void sendMedia(
} }
bool isAyuForwardNeeded(const std::vector<not_null<HistoryItem*>> &items) { bool isAyuForwardNeeded(const std::vector<not_null<HistoryItem*>> &items) {
const auto needAyuForward = [&](const auto &item) for (const auto &item : items) {
{ if (isAyuForwardNeeded(item)) {
return isAyuForwardNeeded(item); return true;
}; }
return std::ranges::any_of(items, needAyuForward); }
return false;
} }
bool isAyuForwardNeeded(not_null<HistoryItem*> item) { bool isAyuForwardNeeded(not_null<HistoryItem*> item) {
@ -242,10 +243,7 @@ void intelligentForward(
const Api::SendAction &action, const Api::SendAction &action,
const Data::ResolvedForwardDraft &draft) { const Data::ResolvedForwardDraft &draft) {
const auto history = action.history; const auto history = action.history;
crl::on_main([&] history->setForwardDraft(action.replyTo.topicRootId, action.replyTo.monoforumPeerId, {});
{
history->setForwardDraft(action.replyTo.topicRootId, action.replyTo.monoforumPeerId, {});
});
const auto items = draft.items; const auto items = draft.items;
const auto peer = history->peer; const auto peer = history->peer;
@ -304,7 +302,7 @@ void forwardMessages(
not_null<Main::Session*> session, not_null<Main::Session*> session,
const Api::SendAction &action, const Api::SendAction &action,
bool forwardState, bool forwardState,
const Data::ResolvedForwardDraft &draft) { Data::ResolvedForwardDraft draft) {
const auto items = draft.items; const auto items = draft.items;
const auto history = action.history; const auto history = action.history;
const auto peer = history->peer; const auto peer = history->peer;
@ -394,23 +392,6 @@ void forwardMessages(
} }
} }
// remove not finished files
for (int j = preparedMedia.files.size() - 1; j >= 0; j--) {
auto &file = preparedMedia.files[j];
QFile f(file.path);
if (groupMedia[j]->photo() && f.size() < groupMedia[j]->photo()->imageByteSize(Data::PhotoSize::Large)
||
groupMedia[j]->document() && f.size() < groupMedia[j]->document()->size
) {
preparedMedia.files.erase(preparedMedia.files.begin() + j);
}
}
if (preparedMedia.files.empty()) {
continue;
}
auto groups = Ui::DivideByGroups( auto groups = Ui::DivideByGroups(
std::move(preparedMedia), std::move(preparedMedia),
way, way,

View file

@ -47,6 +47,6 @@ void forwardMessages(
not_null<Main::Session*> session, not_null<Main::Session*> session,
const Api::SendAction &action, const Api::SendAction &action,
bool forwardState, bool forwardState,
const Data::ResolvedForwardDraft &draft); Data::ResolvedForwardDraft draft);
} }

View file

@ -55,7 +55,7 @@ private:
namespace AyuSync { namespace AyuSync {
QString pathForSave(not_null<Main::Session*> session) { QString pathForSave(not_null<Main::Session*> session) {
auto path = Core::App().settings().downloadPath(); const auto path = Core::App().settings().downloadPath();
if (path.isEmpty()) { if (path.isEmpty()) {
return File::DefaultDownloadPath(session); return File::DefaultDownloadPath(session);
} }
@ -66,10 +66,6 @@ QString pathForSave(not_null<Main::Session*> session) {
} }
QString filePath(not_null<Main::Session*> session, const Data::Media *media) { QString filePath(not_null<Main::Session*> session, const Data::Media *media) {
if (!media) {
return {};
}
if (const auto document = media->document()) { if (const auto document = media->document()) {
if (!document->filename().isEmpty()) { if (!document->filename().isEmpty()) {
return pathForSave(session) + media->document()->filename(); return pathForSave(session) + media->document()->filename();
@ -89,7 +85,7 @@ QString filePath(not_null<Main::Session*> session, const Data::Media *media) {
return pathForSave(session) + QString::number(photo->getDC()) + "_" + QString::number(photo->id) + ".jpg"; return pathForSave(session) + QString::number(photo->getDC()) + "_" + QString::number(photo->id) + ".jpg";
} }
return {}; return QString();
} }
qint64 fileSize(not_null<HistoryItem*> item) { qint64 fileSize(not_null<HistoryItem*> item) {
@ -132,13 +128,9 @@ void loadDocumentSync(not_null<Main::Session*> session, DocumentData *data, not_
auto latch = std::make_shared<TimedCountDownLatch>(1); auto latch = std::make_shared<TimedCountDownLatch>(1);
auto lifetime = std::make_shared<rpl::lifetime>(); auto lifetime = std::make_shared<rpl::lifetime>();
auto path = filePath(session, item->media());
if (path.isEmpty()) {
return;
}
crl::on_main([&] crl::on_main([&]
{ {
data->save(Data::FileOriginMessage(item->fullId()), path); data->save(Data::FileOriginMessage(item->fullId()), filePath(session, item->media()));
rpl::single() | rpl::then( rpl::single() | rpl::then(
session->downloaderTaskFinished() session->downloaderTaskFinished()
@ -148,26 +140,12 @@ void loadDocumentSync(not_null<Main::Session*> session, DocumentData *data, not_
}) | rpl::start_with_next([&]() mutable }) | rpl::start_with_next([&]() mutable
{ {
latch->countDown(); latch->countDown();
base::take(lifetime)->destroy();
}, },
*lifetime); *lifetime);
}); });
latch->await(std::chrono::minutes(5));
constexpr auto overall = std::chrono::minutes(15);
const auto startTime = std::chrono::steady_clock::now();
while (std::chrono::steady_clock::now() - startTime < overall) {
if (latch->await(std::chrono::minutes(5))) {
break;
}
if (!data->loading()) {
break;
}
}
base::take(lifetime)->destroy();
} }
void forwardMessagesSync(not_null<Main::Session*> session, void forwardMessagesSync(not_null<Main::Session*> session,
@ -242,11 +220,11 @@ void loadPhotoSync(not_null<Main::Session*> session, const std::pair<not_null<Ph
{ {
saveToFiles(); saveToFiles();
latch->countDown(); latch->countDown();
base::take(lifetime)->destroy();
}, },
*lifetime); *lifetime);
}); });
latch->await(std::chrono::minutes(5)); latch->await(std::chrono::minutes(5));
base::take(lifetime)->destroy();
} }
} }
@ -277,12 +255,12 @@ void waitForMsgSync(not_null<Main::Session*> session, const Api::SendAction &act
}) | rpl::start_with_next([&] }) | rpl::start_with_next([&]
{ {
latch->countDown(); latch->countDown();
base::take(lifetime)->destroy();
}, },
*lifetime); *lifetime);
}); });
latch->await(std::chrono::minutes(5)); latch->await(std::chrono::minutes(2));
base::take(lifetime)->destroy();
} }
void sendDocumentSync(not_null<Main::Session*> session, void sendDocumentSync(not_null<Main::Session*> session,

View file

@ -37,7 +37,6 @@ const QVector<QString> icons{
AyuAssets::CHIBI2_ICON, AyuAssets::CHIBI2_ICON,
AyuAssets::EXTERA2_ICON, AyuAssets::EXTERA2_ICON,
}; };
std::unordered_map<QString, QImage> cachedIcons;
const auto rows = static_cast<int>(icons.size()) / 4 + std::min(1, static_cast<int>(icons.size()) % 4); const auto rows = static_cast<int>(icons.size()) / 4 + std::min(1, static_cast<int>(icons.size()) % 4);
@ -84,9 +83,6 @@ IconPicker::IconPicker(QWidget *parent)
setMinimumSize(st::boxWidth, (st::cpIconSize + st::cpPadding) * rows - st::cpPadding); setMinimumSize(st::boxWidth, (st::cpIconSize + st::cpPadding) * rows - st::cpPadding);
} }
IconPicker::~IconPicker() {
cachedIcons.clear();
}
void IconPicker::paintEvent(QPaintEvent *e) { void IconPicker::paintEvent(QPaintEvent *e) {
Painter p(this); Painter p(this);
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
@ -102,16 +98,10 @@ void IconPicker::paintEvent(QPaintEvent *e) {
if (iconName.isEmpty()) { if (iconName.isEmpty()) {
continue; continue;
} }
QImage icon;
if (const auto cached = cachedIcons.find(iconName); cached != cachedIcons.end()) { auto icon = AyuAssets::loadPreview(iconName)
icon = cached->second; .scaled(st::cpIconSize, st::cpIconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
} else {
icon = cachedIcons[iconName] = AyuAssets::loadPreview(iconName).scaled(
st::cpIconSize,
st::cpIconSize,
Qt::KeepAspectRatio,
Qt::SmoothTransformation);
}
auto opacity = 0.0f; auto opacity = 0.0f;
if (iconName == wasSelected) { if (iconName == wasSelected) {
opacity = 1.0f - animation.value(1.0f); opacity = 1.0f - animation.value(1.0f);

View file

@ -13,7 +13,6 @@ class IconPicker : public Ui::RpWidget
{ {
public: public:
IconPicker(QWidget *parent); IconPicker(QWidget *parent);
~IconPicker();
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;