aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sx-question-list.el2
-rw-r--r--sx-question.el13
2 files changed, 9 insertions, 6 deletions
diff --git a/sx-question-list.el b/sx-question-list.el
index 773ce0d..b220097 100644
--- a/sx-question-list.el
+++ b/sx-question-list.el
@@ -226,7 +226,7 @@ Used in the questions list to indicate a question was updated \"4d ago\"."
'face (if .upvoted 'sx-question-list-score-upvoted
'sx-question-list-score))
(list (int-to-string .answer_count)
- 'face (if (sx-question--accepted-answer data)
+ 'face (if (sx-question--accepted-answer-id data)
'sx-question-list-answers-accepted
'sx-question-list-answers))
(concat
diff --git a/sx-question.el b/sx-question.el
index 768e5db..fc44bd8 100644
--- a/sx-question.el
+++ b/sx-question.el
@@ -71,16 +71,17 @@
Each element has the form (SITE . QUESTION-LIST).
And each element in QUESTION-LIST has the form (QUESTION_ID . LAST-VIEWED-DATE).")
-(defun sx-question--ensure-read-list ()
- "Ensure the `sx-question--user-read-list' has been read from cache."
+(defun sx-question--ensure-read-list (site)
+ "Ensure the `sx-question--user-read-list' has been read from cache.
+If no cache exists for it, initialize one with SITE."
(unless sx-question--user-read-list
(setq sx-question--user-read-list
- (sx-cache-get 'read-questions))))
+ (sx-cache-get 'read-questions `(list ,site)))))
(defun sx-question--read-p (question)
"Non-nil if QUESTION has been read since last updated."
- (sx-question--ensure-read-list)
(sx-assoc-let question
+ (sx-question--ensure-read-list .site)
(let ((ql (cdr (assoc .site sx-question--user-read-list))))
(and ql
(>= (or (cdr (assoc .question_id ql)) 0)
@@ -88,8 +89,8 @@ And each element in QUESTION-LIST has the form (QUESTION_ID . LAST-VIEWED-DATE).
(defun sx-question--mark-read (question)
"Mark QUESTION as being read, until it is updated again."
- (sx-question--ensure-read-list)
(sx-assoc-let question
+ (sx-question--ensure-read-list .site)
(let ((site-cell (assoc .site sx-question--user-read-list))
(q-cell (cons .question_id .last_activity_date))
cell)
@@ -103,6 +104,8 @@ And each element in QUESTION-LIST has the form (QUESTION_ID . LAST-VIEWED-DATE).
;; Question wasn't present.
(t
(setcdr site-cell (cons q-cell (cdr site-cell)))))))
+ ;; This causes a small lag on `j' and `k' as the list gets large.
+ ;; Should we do this on a timer?
;; Save the results.
(sx-cache-set 'read-questions sx-question--user-read-list))