aboutsummaryrefslogtreecommitdiff
path: root/sx-networks.el
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2014-11-18 13:32:51 -0500
committerSean Allred <code@seanallred.com>2014-11-18 13:32:51 -0500
commit0b2a393bb232c3da5362b45def6371d2c7d72b27 (patch)
tree8c4bdcb25855453324ab965c5afdceda17128ff4 /sx-networks.el
parentc0a4f017ca56f8d8ba174231d9f1f3f64fa0a9a4 (diff)
parent8554d48ef764c8ca44438f35243a88f54f8386dc (diff)
Merge pull request #70 from jleechpe/sx-networks
Update sx-networks and sx-favorites to use sx-initialize
Diffstat (limited to 'sx-networks.el')
-rw-r--r--sx-networks.el36
1 files changed, 19 insertions, 17 deletions
diff --git a/sx-networks.el b/sx-networks.el
index 315daba..755d62c 100644
--- a/sx-networks.el
+++ b/sx-networks.el
@@ -56,28 +56,30 @@
"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
+ (or (and (setq sx-network--user-information (sx-cache-get 'network-user)
+ 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)))
- sx-network--user-filter
- 'warn))
- (setq sx-network--user-sites (sx-network--map-site-url-to-site-api))
- (sx-cache-set 'network-user sx-network--user-information))
-
-(defun sx-network--ensure-user ()
- "Ensure user-cache is available.
-
-This should be called during initialization."
+ "Update user information.
+
+Sets cache and then uses `sx-network--get-associated' to update
+the variables."
+ (sx-cache-set 'network-user
+ (sx-method-call "me/associated"
+ '((types . (main_site meta_site)))
+ sx-network--user-filter
+ 'warn))
+ (sx-network--get-associated))
+
+(defun sx-network--initialize ()
+ "Ensure network-user cache is available.
+
+Added as hook to initialization."
;; Cache was not retrieved, retrieve it.
- (unless sx-network--user-information
- (sx-network--get-associated)))
+ (sx-network--get-associated))
+(add-hook 'sx-init--internal-hook #'sx-network--initialize)
(defun sx-network--map-site-url-to-site-api ()
"Convert `me/associations' to a set of `api_site_parameter's.