Commit 832a9a8f authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Hardcode the state the snap is going to get

parent e324fd7f
......@@ -191,13 +191,13 @@ Transaction* SnapBackend::installApplication(AbstractResource* app, const AddonL
Transaction* SnapBackend::installApplication(AbstractResource* _app)
{
auto app = qobject_cast<SnapResource*>(_app);
return new SnapTransaction(app, m_client.install(app->packageName()), Transaction::InstallRole);
return new SnapTransaction(app, m_client.install(app->packageName()), Transaction::InstallRole, AbstractResource::Installed);
}
Transaction* SnapBackend::removeApplication(AbstractResource* _app)
{
auto app = qobject_cast<SnapResource*>(_app);
return new SnapTransaction(app, m_client.remove(app->packageName()), Transaction::RemoveRole);
return new SnapTransaction(app, m_client.remove(app->packageName()), Transaction::RemoveRole, AbstractResource::None);
}
QString SnapBackend::displayName() const
......
......@@ -29,10 +29,11 @@
#include "libsnapclient/config-paths.h"
#include "utils.h"
SnapTransaction::SnapTransaction(SnapResource* app, QSnapdRequest* request, Role role)
SnapTransaction::SnapTransaction(SnapResource* app, QSnapdRequest* request, Role role, AbstractResource::State newState)
: Transaction(app, app, role)
, m_app(app)
, m_request(request)
, m_newState(newState)
{
setStatus(DownloadingStatus);
setCancellable(false);
......@@ -53,7 +54,7 @@ void SnapTransaction::finishTransaction()
qDebug() << "done!";
switch(m_request->error()) {
case QSnapdRequest::NoError:
static_cast<SnapBackend*>(m_app->backend())->refreshStates();
m_app->setState(m_newState);
break;
case QSnapdRequest::AuthDataRequired: {
QProcess* p = new QProcess;
......
......@@ -21,6 +21,7 @@
#ifndef SNAPTRANSACTION_H
#define SNAPTRANSACTION_H
#include <resources/AbstractResource.h>
#include <Transaction/Transaction.h>
#include <QPointer>
......@@ -31,7 +32,7 @@ class SnapTransaction : public Transaction
{
Q_OBJECT
public:
SnapTransaction(SnapResource* app, QSnapdRequest* request, Role role);
SnapTransaction(SnapResource* app, QSnapdRequest* request, Role role, AbstractResource::State newState);
void cancel() override;
......@@ -43,6 +44,7 @@ class SnapTransaction : public Transaction
SnapResource * const m_app;
const QScopedPointer<QSnapdRequest> m_request;
const AbstractResource::State m_newState;
};
#endif // SNAPTRANSACTION_H
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