Commit 69ef7cfe authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Make sure we don't request multiple times the notification icon

Reviewers: #kde_connect, albertvaka

Reviewed By: #kde_connect, albertvaka

Subscribers: albertvaka

Differential Revision: https://phabricator.kde.org/D11371
parent 01159b1a
......@@ -134,14 +134,17 @@ KNotification* Notification::createKNotification(bool update, const NetworkPacke
void Notification::loadIcon(const NetworkPacket& np)
{
if (m_job)
return;
m_ready = false;
FileTransferJob* job = np.createPayloadTransferJob(QUrl::fromLocalFile(m_iconPath));
job->start();
m_job = np.createPayloadTransferJob(QUrl::fromLocalFile(m_iconPath));
m_job->start();
connect(job, &FileTransferJob::result, this, [this, job]{
connect(m_job, &FileTransferJob::result, this, [this]{
if (job->error()) {
qCDebug(KDECONNECT_PLUGIN_NOTIFICATION) << "Error in FileTransferJob: " << job->errorString();
if (m_job->error()) {
qCDebug(KDECONNECT_PLUGIN_NOTIFICATION) << "Error in FileTransferJob: " << m_job->errorString();
applyNoIcon();
} else {
applyIcon();
......
......@@ -25,6 +25,7 @@
#include <QString>
#include <KNotification>
#include <QDir>
#include <QPointer>
#include <core/networkpacket.h>
......@@ -89,6 +90,7 @@ private:
bool m_closed;
QString m_payloadHash;
bool m_ready;
QPointer<FileTransferJob> m_job;
void parseNetworkPacket(const NetworkPacket& np);
void loadIcon(const NetworkPacket& np);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment