diff options
author | mousebot <mousebot@riseup.net> | 2021-10-29 19:00:22 +0200 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-10-29 19:03:31 +0200 |
commit | 158bfd8785e46f134f699c5d6423e8c1785daf1c (patch) | |
tree | 4ea696f0f565c1eb6861d96975ec12f77f19ca24 /lisp | |
parent | 39a54a6aaf1a6f043bfe8769ef0c3484de917e7c (diff) |
make get-max-toot-chars async
Diffstat (limited to 'lisp')
-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 309b64a..3e3619c 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -154,12 +154,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. |