Revert "Use appid between homescreen-service and apps"
[apps/mixer.git] / app / mixer.cpp
index 6614569..f231b6d 100644 (file)
@@ -61,7 +61,7 @@ void Mixer::setVolume(const QString& name, int value)
     QJsonObject arg;
     arg.insert("action", "volume");
     arg.insert("value", QJsonValue(value));
-    m_client.call("ahl-4a", name, arg, [this, name](bool r, const QJsonValue& v) {
+    m_client.call("ahl-4a", name, arg, [name](bool r, const QJsonValue& v) {
         if (r && v.isObject())
         {
                        // TODO: Success, update the slider
@@ -82,6 +82,14 @@ void Mixer::getVolume(const QString& name)
         if (r && v.isObject())
         {
                        // TODO: Success, update the slider
+            qDebug() << "Volume changed: " << v;
+            int newVolume = v.toObject()["response"].toObject()["response"].toObject()["volnew"].toInt();
+            auto currentVolume = volumes_.find(name);
+            if (currentVolume != volumes_.end() && *currentVolume == newVolume)
+                return;
+
+            volumes_[name] = newVolume;
+            emit volumeChanged(name, newVolume);
         }
         else
         {