From 620e5225f2636e95c1b9e5d942176313ff5ffe04 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 3 Apr 2017 21:19:14 +0200 Subject: [PATCH] Support token system in Qml app to reduce polling Main window keep track centrally of all valid tokens, a Timer coupled with it's own instance of LibresapiLocalClient refresh periodically valid tokens, registerToken and isTokenValid are offered to child components to operate without polling Main window coreStateCheckTimer is stopped after login --- retroshare-qml-app/src/qml/main.qml | 142 ++++++++++++++++++++-------- 1 file changed, 103 insertions(+), 39 deletions(-) diff --git a/retroshare-qml-app/src/qml/main.qml b/retroshare-qml-app/src/qml/main.qml index 6778fc85f..c67b3d868 100644 --- a/retroshare-qml-app/src/qml/main.qml +++ b/retroshare-qml-app/src/qml/main.qml @@ -28,6 +28,33 @@ ApplicationWindow width: 400 height: 400 + property var tokens: ({}) + function registerToken(token, callback) + { + if (Array.isArray(tokens[token])) tokens[token].push(callback) + else tokens[token] = [callback] + } + function tokenExpire(token) + { + if(Array.isArray(tokens[token])) + { + var arrLen = tokens[token].length + for(var i=0; i