diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-12-02 15:26:28 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-12-02 15:26:28 +0000 |
commit | 07dc04e1e5111fff7f2905a155271edde3ce754c (patch) | |
tree | 54939c415040a6b09292a2c562f586e3a07dbf04 /sx-question.el | |
parent | cc7fd3336e0ee40280d343ba80cb1e89498f725e (diff) | |
parent | 8795a394f90f143239edeabd870bf0767303543d (diff) |
Merge pull request #126 from vermiculus/improve-display-engine
Improve display engine
Diffstat (limited to 'sx-question.el')
-rw-r--r-- | sx-question.el | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/sx-question.el b/sx-question.el index 00b5f7f..c4b2445 100644 --- a/sx-question.el +++ b/sx-question.el @@ -88,27 +88,32 @@ See `sx-question--user-read-list'." (defun sx-question--mark-read (question) "Mark QUESTION as being read until it is updated again. +Returns nil if question (in its current state) was already marked +read, i.e., if it was `sx-question--read-p'. See `sx-question--user-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) - (cond - ;; First question from this site. - ((null site-cell) - (push (list .site q-cell) sx-question--user-read-list)) - ;; Question already has an older time. - ((setq cell (assoc .question_id site-cell)) - (setcdr cell .last_activity_date)) - ;; Question wasn't present. - (t - (sx-sorted-insert-skip-first - q-cell site-cell (lambda (x y) (> (car x) (car y)))))))) - ;; Save the results. - ;; @TODO This causes a small lag on `j' and `k' as the list gets - ;; large. Should we do this on a timer? - (sx-cache-set 'read-questions sx-question--user-read-list)) + (prog1 + (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) + (cond + ;; First question from this site. + ((null site-cell) + (push (list .site q-cell) sx-question--user-read-list)) + ;; Question already present. + ((setq cell (assoc .question_id site-cell)) + ;; Current version is newer than cached version. + (when (> .last_activity_date (cdr cell)) + (setcdr cell .last_activity_date))) + ;; Question wasn't present. + (t + (sx-sorted-insert-skip-first + q-cell site-cell (lambda (x y) (> (car x) (car y)))))))) + ;; Save the results. + ;; @TODO This causes a small lag on `j' and `k' as the list gets + ;; large. Should we do this on a timer? + (sx-cache-set 'read-questions sx-question--user-read-list))) ;;;; Hidden |