aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-tl.el
diff options
context:
space:
mode:
authorJohnson Denen <johnson.denen@gmail.com>2017-04-17 12:53:14 -0400
committerJohnson Denen <johnson.denen@gmail.com>2017-04-17 13:01:13 -0400
commite58de9ad62dca7750b28c4d2e6f27f08d4cc894c (patch)
treee81b7db3d20c0e391fb15514eb4eef54ab33e731 /lisp/mastodon-tl.el
parent77f514a48d21b31fd216f78ebdef7d098c05f3b0 (diff)
Reimplement update post-rewrite
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r--lisp/mastodon-tl.el28
1 files changed, 28 insertions, 0 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 7eb3104..4c4e14c 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -135,6 +135,34 @@
(html2text)
(replace-regexp "\n\n\n" "\n" nil (point-min) (point-max)))
+;; TODO
+;; Look into the JSON returned here by Local
+(defun mastodon-tl--updated-json (timeline id)
+ "Return JSON for TIMELINE since ID."
+ (let ((url (mastodon--api-for (concat "timelines/"
+ timeline
+ "?since_id="
+ (number-to-string id)))))
+ (mastodon-http--get-json url)))
+
+(defun mastodon-tl--newest-id ()
+ "Return toot-id from the top of the buffer."
+ (goto-char (point-min))
+ (mastodon-tl--goto-next-toot)
+ (get-text-property (point) 'toot-id))
+
+(defun mastodon-tl--update ()
+ "Update timeline with new toots."
+ (interactive)
+ (let* ((tl (mastodon-tl--timeline-name))
+ (id (mastodon-tl--newest-id))
+ (json (mastodon-tl--updated-json tl id)))
+ (when json
+ (with-current-buffer (current-buffer)
+ (let ((inhibit-read-only t))
+ (goto-char (point-min))
+ (mastodon-tl--timeline json))))))
+
(defun mastodon-tl--get (timeline)
"Display TIMELINE in buffer."
(let* ((url (mastodon--api-for (concat "timelines/" timeline)))