diff options
author | Jonathan Leech-Pepin <jonathan.leechpepin@gmail.com> | 2014-11-18 07:26:51 -0500 |
---|---|---|
committer | Jonathan Leech-Pepin <jonathan.leechpepin@gmail.com> | 2014-11-18 07:26:51 -0500 |
commit | 1715dfecb488bcfd487e1150adc92875aa2f8c10 (patch) | |
tree | b8ff7afe1d2c0e6d09306f79209a329abab67b6a | |
parent | 6a7e345bb776c715c0801674ff4cc5feaef08f4c (diff) |
Fixes as per github comments.
(sx-network--get-associated): Ensure user-sites is also set when
retrieving cache.
(sx-network--ensure-user): Simplify. Used to ensure cache is loaded
before attempting to use it.
Fix quoted lambda in sx-network--map-site-url-to-site-api.
-rw-r--r-- | sx-networks.el | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/sx-networks.el b/sx-networks.el index 2be764f..ead4d6d 100644 --- a/sx-networks.el +++ b/sx-networks.el @@ -53,15 +53,19 @@ none)) (defun sx-network--get-associated () - (or (sx-cache-get - 'network-user) - (sx-network--update)) + "Retrieve cached information for network user. + +If cache is not available, retrieve current data." + (or (and (sx-cache-get 'network-user) + (setq sx-network--user-sites + (sx-network--map-site-url-to-site-api))) + (sx-network--update))) (defun sx-network--update () "Update user information." (setq sx-network--user-information (sx-method-call "me/associated" - '((types . "main_site;meta_site")) + '((types . (main_site meta_site))) sx-network--user-filter 'warn)) (setq sx-network--user-sites (sx-network--map-site-url-to-site-api)) @@ -71,13 +75,9 @@ "Ensure user-cache is available. This should be called during initialization." - (cond - ((not sx-network--user-information) - (or (sx-network--get-associated) - (sx-network--update))) - ((not sx-network--user-sites) - (setq sx-network--user-sites - (sx-network--map-site-url-to-site-api))))) + ;; Cache was not retrieved, retrieve it. + (unless sx-network--user-information + (sx-network--get-associated))) (defun sx-network--map-site-url-to-site-api () "Convert `me/associations' to a set of `api_site_parameter's. @@ -90,10 +90,10 @@ list of sites the user is active on." (cdr (assoc 'api_site_parameter x)))) (sx-site--get-site-list)))) - (mapcar '(lambda (loc) - (let ((u-site (cdr (assoc 'site_url loc)))) - (when (member u-site (mapcar 'car sites-info)) - (cdr (assoc u-site sites-info))))) + (mapcar (lambda (loc) + (let ((u-site (cdr (assoc 'site_url loc)))) + (when (member u-site (mapcar 'car sites-info)) + (cdr (assoc u-site sites-info))))) sx-network--user-information))) (defvar sx-network--user-information nil |