From 8931eec5b0f39aa5526e601c68d7e311846bf324 Mon Sep 17 00:00:00 2001 From: buinsky Date: Fri, 30 Jan 2015 01:01:41 +0300 Subject: [PATCH] Use server refresh interval Use torrents table refresh interval from server in web-client. --- src/webui/btjson.cpp | 4 ++++ src/webui/www/public/scripts/client.js | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/webui/btjson.cpp b/src/webui/btjson.cpp index d5deb38cf..e70ba5ffc 100644 --- a/src/webui/btjson.cpp +++ b/src/webui/btjson.cpp @@ -147,6 +147,7 @@ static const char KEY_TRANSFER_CONNECTION_STATUS[] = "connection_status"; // Sync main data keys static const char KEY_SYNC_MAINDATA_QUEUEING[] = "queueing"; static const char KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS[] = "use_alt_speed_limits"; +static const char KEY_SYNC_MAINDATA_REFRESH_INTERVAL[] = "refresh_interval"; static const char KEY_FULL_UPDATE[] = "full_update"; static const char KEY_RESPONSE_ID[] = "rid"; @@ -306,6 +307,7 @@ QByteArray btjson::getTorrents(QString filter, QString label, * - "up_info_speed: upload speed * - "up_rate_limit: upload speed limit * - "queueing": priority system usage flag + * - "refresh_interval": torrents table refresh interval */ QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData, QVariantMap &lastAcceptedData) { @@ -335,6 +337,7 @@ QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData QVariantMap serverState = getTranserInfoMap(); serverState[KEY_SYNC_MAINDATA_QUEUEING] = QBtSession::instance()->isQueueingEnabled(); serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = Preferences::instance()->isAltBandwidthEnabled(); + serverState[KEY_SYNC_MAINDATA_REFRESH_INTERVAL] = Preferences::instance()->getRefreshInterval(); data["server_state"] = serverState; return json::toJson(generateSyncData(acceptedResponseId, data, lastAcceptedData, lastData)); @@ -610,6 +613,7 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData) case QVariant::Bool: case QVariant::Double: case QVariant::ULongLong: + case QVariant::UInt: if (prevData[key] != data[key]) syncData[key] = data[key]; break; diff --git a/src/webui/www/public/scripts/client.js b/src/webui/www/public/scripts/client.js index 92c11e755..7ad60e2a6 100644 --- a/src/webui/www/public/scripts/client.js +++ b/src/webui/www/public/scripts/client.js @@ -28,6 +28,7 @@ var updatePropertiesPanel = function(){}; var updateMainData = function(){}; var alternativeSpeedLimits = false; var queueing_enabled = true; +var syncMainDataTimerPeriod = 1500; selected_filter = getLocalStorageItem('selected_filter', 'all'); selected_label = null; @@ -174,7 +175,7 @@ window.addEvent('load', function () { } } clearTimeout(syncMainDataTimer); - syncMainDataTimer = syncMainData.delay(1500); + syncMainDataTimer = syncMainData.delay(syncMainDataTimerPeriod); } }).send(); }; @@ -228,6 +229,10 @@ window.addEvent('load', function () { alternativeSpeedLimits = serverState.use_alt_speed_limits; updateAltSpeedIcon(alternativeSpeedLimits); } + + syncMainDataTimerPeriod = serverState.refresh_interval; + if (syncMainDataTimerPeriod < 500) + syncMainDataTimerPeriod = 500; }; var updateAltSpeedIcon = function(enabled) {