mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-09-06 20:13:12 +02:00
Compare commits
No commits in common. "dev" and "v5.16.4" have entirely different histories.
6 changed files with 22 additions and 80 deletions
|
@ -15,10 +15,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_item.h"
|
||||
#include "main/main_session.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
|
||||
|
||||
namespace Api {
|
||||
namespace {
|
||||
|
||||
|
@ -87,8 +83,6 @@ void ViewsManager::pollExtendedMedia(
|
|||
}
|
||||
|
||||
void ViewsManager::viewsIncrement() {
|
||||
const auto &settings = AyuSettings::getInstance();
|
||||
|
||||
for (auto i = _toIncrement.begin(); i != _toIncrement.cend();) {
|
||||
if (_incrementRequests.contains(i->first)) {
|
||||
++i;
|
||||
|
@ -103,7 +97,7 @@ void ViewsManager::viewsIncrement() {
|
|||
const auto requestId = _api.request(MTPmessages_GetMessagesViews(
|
||||
i->first->input,
|
||||
MTP_vector<MTPint>(ids),
|
||||
MTP_bool(settings.sendReadMessages)
|
||||
MTP_bool(true)
|
||||
)).done([=](
|
||||
const MTPmessages_MessageViews &result,
|
||||
mtpRequestId requestId) {
|
||||
|
|
|
@ -213,11 +213,12 @@ void sendMedia(
|
|||
}
|
||||
|
||||
bool isAyuForwardNeeded(const std::vector<not_null<HistoryItem*>> &items) {
|
||||
const auto needAyuForward = [&](const auto &item)
|
||||
{
|
||||
return isAyuForwardNeeded(item);
|
||||
};
|
||||
return std::ranges::any_of(items, needAyuForward);
|
||||
for (const auto &item : items) {
|
||||
if (isAyuForwardNeeded(item)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isAyuForwardNeeded(not_null<HistoryItem*> item) {
|
||||
|
@ -242,10 +243,7 @@ void intelligentForward(
|
|||
const Api::SendAction &action,
|
||||
const Data::ResolvedForwardDraft &draft) {
|
||||
const auto history = action.history;
|
||||
crl::on_main([&]
|
||||
{
|
||||
history->setForwardDraft(action.replyTo.topicRootId, action.replyTo.monoforumPeerId, {});
|
||||
});
|
||||
|
||||
const auto items = draft.items;
|
||||
const auto peer = history->peer;
|
||||
|
@ -304,7 +302,7 @@ void forwardMessages(
|
|||
not_null<Main::Session*> session,
|
||||
const Api::SendAction &action,
|
||||
bool forwardState,
|
||||
const Data::ResolvedForwardDraft &draft) {
|
||||
Data::ResolvedForwardDraft draft) {
|
||||
const auto items = draft.items;
|
||||
const auto history = action.history;
|
||||
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(
|
||||
std::move(preparedMedia),
|
||||
way,
|
||||
|
|
|
@ -47,6 +47,6 @@ void forwardMessages(
|
|||
not_null<Main::Session*> session,
|
||||
const Api::SendAction &action,
|
||||
bool forwardState,
|
||||
const Data::ResolvedForwardDraft &draft);
|
||||
Data::ResolvedForwardDraft draft);
|
||||
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ private:
|
|||
namespace AyuSync {
|
||||
|
||||
QString pathForSave(not_null<Main::Session*> session) {
|
||||
auto path = Core::App().settings().downloadPath();
|
||||
const auto path = Core::App().settings().downloadPath();
|
||||
if (path.isEmpty()) {
|
||||
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) {
|
||||
if (!media) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (const auto document = media->document()) {
|
||||
if (!document->filename().isEmpty()) {
|
||||
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 {};
|
||||
return QString();
|
||||
}
|
||||
|
||||
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 lifetime = std::make_shared<rpl::lifetime>();
|
||||
|
||||
auto path = filePath(session, item->media());
|
||||
if (path.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
crl::on_main([&]
|
||||
{
|
||||
data->save(Data::FileOriginMessage(item->fullId()), path);
|
||||
data->save(Data::FileOriginMessage(item->fullId()), filePath(session, item->media()));
|
||||
|
||||
rpl::single() | rpl::then(
|
||||
session->downloaderTaskFinished()
|
||||
|
@ -148,26 +140,12 @@ void loadDocumentSync(not_null<Main::Session*> session, DocumentData *data, not_
|
|||
}) | rpl::start_with_next([&]() mutable
|
||||
{
|
||||
latch->countDown();
|
||||
base::take(lifetime)->destroy();
|
||||
},
|
||||
*lifetime);
|
||||
});
|
||||
|
||||
|
||||
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();
|
||||
latch->await(std::chrono::minutes(5));
|
||||
}
|
||||
|
||||
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();
|
||||
latch->countDown();
|
||||
base::take(lifetime)->destroy();
|
||||
},
|
||||
*lifetime);
|
||||
});
|
||||
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([&]
|
||||
{
|
||||
latch->countDown();
|
||||
base::take(lifetime)->destroy();
|
||||
},
|
||||
*lifetime);
|
||||
});
|
||||
|
||||
latch->await(std::chrono::minutes(5));
|
||||
base::take(lifetime)->destroy();
|
||||
latch->await(std::chrono::minutes(2));
|
||||
}
|
||||
|
||||
void sendDocumentSync(not_null<Main::Session*> session,
|
||||
|
|
|
@ -37,7 +37,6 @@ const QVector<QString> icons{
|
|||
AyuAssets::CHIBI2_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);
|
||||
|
||||
|
@ -84,9 +83,6 @@ IconPicker::IconPicker(QWidget *parent)
|
|||
setMinimumSize(st::boxWidth, (st::cpIconSize + st::cpPadding) * rows - st::cpPadding);
|
||||
}
|
||||
|
||||
IconPicker::~IconPicker() {
|
||||
cachedIcons.clear();
|
||||
}
|
||||
void IconPicker::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
PainterHighQualityEnabler hq(p);
|
||||
|
@ -102,16 +98,10 @@ void IconPicker::paintEvent(QPaintEvent *e) {
|
|||
if (iconName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
QImage icon;
|
||||
if (const auto cached = cachedIcons.find(iconName); cached != cachedIcons.end()) {
|
||||
icon = cached->second;
|
||||
} else {
|
||||
icon = cachedIcons[iconName] = AyuAssets::loadPreview(iconName).scaled(
|
||||
st::cpIconSize,
|
||||
st::cpIconSize,
|
||||
Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
auto icon = AyuAssets::loadPreview(iconName)
|
||||
.scaled(st::cpIconSize, st::cpIconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
auto opacity = 0.0f;
|
||||
if (iconName == wasSelected) {
|
||||
opacity = 1.0f - animation.value(1.0f);
|
||||
|
|
|
@ -13,7 +13,6 @@ class IconPicker : public Ui::RpWidget
|
|||
{
|
||||
public:
|
||||
IconPicker(QWidget *parent);
|
||||
~IconPicker();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
|
Loading…
Add table
Reference in a new issue