From 2786cec76ad150fe4be79c1f29a77df9413f9b48 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 3 Apr 2017 21:35:42 +0200 Subject: [PATCH] TrustedNodesView.qml got rid of polling --- .../src/qml/TrustedNodesView.qml | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/retroshare-qml-app/src/qml/TrustedNodesView.qml b/retroshare-qml-app/src/qml/TrustedNodesView.qml index e7607d733..82f18ec8b 100644 --- a/retroshare-qml-app/src/qml/TrustedNodesView.qml +++ b/retroshare-qml-app/src/qml/TrustedNodesView.qml @@ -24,14 +24,20 @@ import "jsonpath.js" as JSONPath Item { id: trustedNodesView + property int token: 0 - function refreshData() - { - rsApi.request("/peers/*", "", - function(par) { jsonModel.json = par.response }) - } + Component.onCompleted: refreshData() onFocusChanged: focus && refreshData() + function refreshDataCallback(par) + { + jsonModel.json = par.response + token = JSON.parse(par.response).statetoken + mainWindow.registerToken(token, refreshData) + } + function refreshData() + { if(visible) rsApi.request("/peers/*", "", refreshDataCallback) } + JSONListModel { id: jsonModel @@ -136,13 +142,4 @@ Item onClicked: stackView.push("qrc:/qml/AddTrustedNode.qml") width: parent.width } - - Timer - { - interval: 800 - repeat: true - triggeredOnStart: true - onTriggered: if(trustedNodesView.visible) trustedNodesView.refreshData() - Component.onCompleted: start() - } }