From 37c1c0bb7904c6b83f8a2e37049ece5af499cce1 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 20 Jun 2016 21:08:09 +0200 Subject: [PATCH] disable right panel by default, don't perform Twitter https call if panel is disabled --- main.qml | 2 +- tabs/TweetsModel.qml | 41 ++++++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/main.qml b/main.qml index e193ae29..0ec6dafc 100644 --- a/main.qml +++ b/main.qml @@ -43,7 +43,7 @@ ApplicationWindow { property var currentItem property bool whatIsEnable: false property bool ctrlPressed: false - property bool rightPanelExpanded: true + property bool rightPanelExpanded: false property bool osx: false property alias persistentSettings : persistentSettings property var wallet; diff --git a/tabs/TweetsModel.qml b/tabs/TweetsModel.qml index 0e9fe004..a6b40aa6 100644 --- a/tabs/TweetsModel.qml +++ b/tabs/TweetsModel.qml @@ -60,30 +60,33 @@ Item { if (from == "" && phrase == "") return; + if (appWindow.rightPanelExpanded) { + //! [requesting] - var req = new XMLHttpRequest; - req.open("GET", "https://api.twitter.com/1.1/search/tweets.json?from=" + from + - "&count=" + tweetsMaxCount + "&q=" + encodePhrase(phrase)); - req.setRequestHeader("Authorization", "Bearer " + bearerToken); - req.onreadystatechange = function() { - status = req.readyState; - if (status === XMLHttpRequest.DONE) { - var objectArray = JSON.parse(req.responseText); - if (objectArray.errors !== undefined) - console.log("Error fetching tweets: " + objectArray.errors[0].message) - else { - for (var key in objectArray.statuses) { - var jsonObject = objectArray.statuses[key]; - tweets.append(jsonObject); + var req = new XMLHttpRequest; + req.open("GET", "https://api.twitter.com/1.1/search/tweets.json?from=" + from + + "&count=" + tweetsMaxCount + "&q=" + encodePhrase(phrase)); + req.setRequestHeader("Authorization", "Bearer " + bearerToken); + req.onreadystatechange = function() { + status = req.readyState; + if (status === XMLHttpRequest.DONE) { + var objectArray = JSON.parse(req.responseText); + if (objectArray.errors !== undefined) + console.log("Error fetching tweets: " + objectArray.errors[0].message) + else { + for (var key in objectArray.statuses) { + var jsonObject = objectArray.statuses[key]; + tweets.append(jsonObject); + } } + if (wasLoading == true) + wrapper.isLoaded() } - if (wasLoading == true) - wrapper.isLoaded() + wasLoading = (status === XMLHttpRequest.LOADING); } - wasLoading = (status === XMLHttpRequest.LOADING); - } - req.send(); + req.send(); //! [requesting] + } }