diff options
author | mousebot <mousebot@riseup.net> | 2021-10-25 11:37:08 +0200 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-10-25 11:37:08 +0200 |
commit | f67558804e899306f6495c934bd25adff814d092 (patch) | |
tree | bcda5a27f9127eb322f902fe0d5cc8c7723b2353 /lisp/mastodon-tl.el | |
parent | 67e515edbbaa660757ecdcf87bbdfe353eb652f2 (diff) |
restore original tl--init as tl--init-sync.
- use it for eg notifications
- this because i suspect sync is sometimes faster.
- with async init*, i often have to press a key to trigger the request
- perhaps good to have both in the code, and choose which to use when
- cd also poss make this a customize.
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r-- | lisp/mastodon-tl.el | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 7f9538b..a7767b8 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1314,5 +1314,36 @@ JSON is the data returned from the server." (current-buffer) nil))))) +(defun mastodon-tl--init-sync (buffer-name endpoint update-function) + "Initialize BUFFER-NAME with timeline targeted by ENDPOINT. + +UPDATE-FUNCTION is used to recieve more toots. +Runs synchronously." + (let* ((url (mastodon-http--api endpoint)) + (buffer (concat "*mastodon-" buffer-name "*")) + (json (mastodon-http--get-json url))) + (with-output-to-temp-buffer buffer + (switch-to-buffer buffer) + (setq + ;; Initialize with a minimal interval; we re-scan at least once + ;; every 5 minutes to catch any timestamps we may have missed + mastodon-tl--timestamp-next-update (time-add (current-time) + (seconds-to-time 300))) + (funcall update-function json)) + (mastodon-mode) + (with-current-buffer buffer + (setq mastodon-tl--buffer-spec + `(buffer-name ,buffer-name + endpoint ,endpoint update-function + ,update-function) + mastodon-tl--timestamp-update-timer + (when mastodon-tl--enable-relative-timestamps + (run-at-time mastodon-tl--timestamp-next-update + nil ;; don't repeat + #'mastodon-tl--update-timestamps-callback + (current-buffer) + nil)))) + buffer)) + (provide 'mastodon-tl) ;;; mastodon-tl.el ends here |