diff --git a/html/background.html b/html/background.html index 7182c66..ff20698 100644 --- a/html/background.html +++ b/html/background.html @@ -16,10 +16,7 @@ button.setBadgeDefaults(); chrome.tabs.onUpdated.addListener(background.prepareBrowserAction); background.watchMail(); - reddit.apiTransmit('GET', 'http://' + reddit.domain + '/reddits/mine.json', null, function (response) { - cache.set('reddits', response.data.children); - console.log(cache.get('reddits')); - }); + reddit.getRedditns(); } window.onload = initBackground; diff --git a/js/common.js b/js/common.js index 07dcca9..92cb8db 100644 --- a/js/common.js +++ b/js/common.js @@ -733,6 +733,19 @@ RedditAPI.prototype.submitComment = function (e) { } }; +/** + * Grabs the logged in user's reddits. + * @alias RedditAPI.getReddits() + * @return {Boolean} Returns true. + * @method + */ +RedditAPI.prototype.getReddits = function () { + reddit.apiTransmit('GET', 'http://' + this.domain + '/reddits/mine.json', null, function (response) { + cache.set('reddits', response.data.children); + return true; + }); +}; + reddit = new RedditAPI('www.reddit.com'); /** @@ -977,7 +990,7 @@ Popup.prototype.createSubmitForm = function (tab) { submitHTML += '
'; submitHTML += ''; submitHTML += ''; - if (redditCache.length > 0) { + if (redditCache !== undefined || reddit.getReddits() === true) { submitHTML += '' + chrome.i18n.getMessage('popular_choices') + ''; submitHTML += '