From e58de9ad62dca7750b28c4d2e6f27f08d4cc894c Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Mon, 17 Apr 2017 12:53:14 -0400 Subject: Reimplement update post-rewrite --- lisp/mastodon-tl.el | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lisp/mastodon-tl.el') 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))) -- cgit v1.2.3