Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Commit

Permalink
only get ratelimit on load if debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
agentlame committed Jul 24, 2015
1 parent 7a9dff6 commit cc47ed0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tbutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ function initwrapper() {
TBUtils.RandomFeedback = RandomFeedbackText[Math.floor(Math.random() * RandomFeedbackText.length)];
TBUtils.log = [];
TBUtils.logModules = [];
TBUtils.rateLimit = 0;
TBUtils.debugMode = TBStorage.getSetting(SETTINGS_NAME, 'debugMode', false);
TBUtils.devMode = TBStorage.getSetting(SETTINGS_NAME, 'devMode', false);
TBUtils.betaMode = TBStorage.getSetting(SETTINGS_NAME, 'betaMode', false);
Expand Down Expand Up @@ -1134,11 +1133,11 @@ function initwrapper() {

// Reddit API stuff
TBUtils.getRatelimit = function getRatelimit(callback) {
$.getJSON('/r/toolbox/wiki/ratelimit.json').done(function (data, status, jqxhr) {
TBUtils.getHead('/r/toolbox/wiki/ratelimit.json',
function (status, jqxhr) {
var ratelimitRemaining = jqxhr.getResponseHeader('x-ratelimit-remaining'),
ratelimitReset = jqxhr.getResponseHeader('x-ratelimit-reset');
$.log('ratelimitRemaining: ' + ratelimitRemaining + ' ratelimitReset: ' + (ratelimitReset / 60), false, SHORTNAME);
TBUtils.rateLimit = ratelimitRemaining;

callback({
'ratelimitRemaining': ratelimitRemaining,
Expand Down Expand Up @@ -1870,9 +1869,11 @@ function initwrapper() {
})();

// get rate limit
(function getRateLimit() {
TBUtils.getRatelimit();
})();
if (TBUtils.debugMode) {
(function getRateLimit() {
TBUtils.getRatelimit();
})();
}

}(TBUtils = window.TBUtils || {}));
}
Expand Down

0 comments on commit cc47ed0

Please sign in to comment.