diff options
author | mousebot <mousebot@riseup.net> | 2021-10-29 19:00:22 +0200 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-10-29 19:00:22 +0200 |
commit | cf13db002b47f8e17267f48a0906be57d01eaf03 (patch) | |
tree | 088be7fee92f36e6412377c0b59bbb8e2c3e2ec5 /lisp/mastodon-toot.el | |
parent | d74f462624b66040a78a3e4a13ccb0d3c681f509 (diff) |
make get-max-toot-chars async
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r-- | lisp/mastodon-toot.el | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 952ff58..57e279f 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -146,12 +146,17 @@ Valid values are \"direct\", \"private\" (followers-only), \"unlisted\", and \"p "Keymap for `mastodon-toot'.") (defun mastodon-toot--get-max-toot-chars () - "Fetch max_toot_chars from `mastodon-instance-url'." - (let ((instance-json (mastodon-http--get-json - (mastodon-http--api "instance")))) - (setq mastodon-toot--max-toot-chars - (number-to-string - (cdr (assoc 'max_toot_chars instance-json)))))) + "Fetch max_toot_chars from `mastodon-instance-url' asynchronously." + (mastodon-http--get-json-async + (mastodon-http--api "instance") 'mastodon-toot--get-max-toot-chars-callback)) + +(defun mastodon-toot--get-max-toot-chars-callback (json-response) + "Set max_toot_chars returned in JSON-RESPONSE." + (setq mastodon-toot--max-toot-chars + (number-to-string + (cdr (assoc 'max_toot_chars json-response)))) + (with-current-buffer "*new toot*" + (mastodon-toot--update-status-fields))) (defun mastodon-toot--action-success (marker byline-region remove) "Insert/remove the text MARKER with 'success face in byline. |