From 621eb496bbf055db2d8cc6ebad0a55e72027f2e3 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Mon, 31 Oct 2016 14:24:13 +0000 Subject: [PATCH] Tweak getRelease callback Simplify the JS processing. --- src/gui/html/js/initialise.js | 10 +--------- src/gui/query/get_version_query.h | 6 +++++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/gui/html/js/initialise.js b/src/gui/html/js/initialise.js index 3c6846c4..b600b542 100644 --- a/src/gui/html/js/initialise.js +++ b/src/gui/html/js/initialise.js @@ -117,16 +117,8 @@ document.addEventListener('loot-game-plugins-change', Game.onPluginsChange); } - function splitVersion(version) { - const lastPeriodIndex = version.lastIndexOf('.'); - return { - release: version.substring(0, lastPeriodIndex), - build: version.substring(lastPeriodIndex + 1), - }; - } - function setVersion(appData) { - return query('getVersion').then(JSON.parse).then(splitVersion).then((version) => { + return query('getVersion').then(JSON.parse).then((version) => { appData.version = version.release; dom.setVersion(version); }); diff --git a/src/gui/query/get_version_query.h b/src/gui/query/get_version_query.h index a477b07c..7df31939 100644 --- a/src/gui/query/get_version_query.h +++ b/src/gui/query/get_version_query.h @@ -27,13 +27,17 @@ along with LOOT. If not, see #include "gui/query/query.h" #include "loot/loot_version.h" +#include "backend/helpers/json.h" namespace loot { class GetVersionQuery : public Query { public: std::string executeLogic() { BOOST_LOG_TRIVIAL(info) << "Getting LOOT version."; - return "\"" + LootVersion::string() + "." + LootVersion::revision + "\""; + YAML::Node node; + node["release"] = LootVersion::string(); + node["build"] = LootVersion::revision; + return JSON::stringify(node); } }; }