TrustedNodesView.qml got rid of polling

This commit is contained in:
Gioacchino Mazzurco 2017-04-03 21:35:42 +02:00
parent 620e5225f2
commit 2786cec76a

View File

@ -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()
}
}