Browse Source

Include category save path in web api sync data

adaptive-webui-19844
Thomas Piccirello 6 years ago
parent
commit
a0e6007fc1
  1. 15
      src/webui/api/synccontroller.cpp
  2. 7
      src/webui/www/private/scripts/client.js

15
src/webui/api/synccontroller.cpp

@ -320,7 +320,7 @@ namespace
// - "full_update": full data update flag // - "full_update": full data update flag
// - "torrents": dictionary contains information about torrents. // - "torrents": dictionary contains information about torrents.
// - "torrents_removed": a list of hashes of removed torrents // - "torrents_removed": a list of hashes of removed torrents
// - "categories": list of categories // - "categories": map of categories info
// - "categories_removed": list of removed categories // - "categories_removed": list of removed categories
// - "server_state": map contains information about the state of the server // - "server_state": map contains information about the state of the server
// The keys of the 'torrents' dictionary are hashes of torrents. // The keys of the 'torrents' dictionary are hashes of torrents.
@ -399,11 +399,16 @@ void SyncController::maindataAction()
data["torrents"] = torrents; data["torrents"] = torrents;
QVariantList categories; QVariantList categoriesList;
for (auto i = session->categories().cbegin(); i != session->categories().cend(); ++i) const auto categories = session->categories();
categories << i.key(); for (auto key : categories.keys()) {
categoriesList << QVariantMap {
{"name", key},
{"savePath", categories.value(key)},
};
}
data["categories"] = categories; data["categories"] = categoriesList;
QVariantMap serverState = getTranserInfo(); QVariantMap serverState = getTranserInfo();
serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled(); serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled();

7
src/webui/www/private/scripts/client.js

@ -317,9 +317,10 @@ window.addEvent('load', function() {
} }
if (response['categories']) { if (response['categories']) {
response['categories'].each(function(category) { response['categories'].each(function(category) {
var categoryHash = genHash(category); var categoryHash = genHash(category.name);
category_list[categoryHash] = { category_list[categoryHash] = {
name: category, name: category.name,
savePath: category.savePath,
torrents: [] torrents: []
}; };
}); });
@ -327,7 +328,7 @@ window.addEvent('load', function() {
} }
if (response['categories_removed']) { if (response['categories_removed']) {
response['categories_removed'].each(function(category) { response['categories_removed'].each(function(category) {
var categoryHash = genHash(category); var categoryHash = genHash(category.name);
delete category_list[categoryHash]; delete category_list[categoryHash];
}); });
update_categories = true; update_categories = true;

Loading…
Cancel
Save