From a8ff368a246c554fc14f0387cee639f19563a3ca Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 22 Aug 2023 18:47:37 +0200 Subject: new var: mastodon-profile-acccount-preferences-data, to reduce requests --- lisp/mastodon-profile.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index de235b3..a89946c 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -109,6 +109,9 @@ extra keybindings." "Holds the JSON data of the CredentialAccount entity, containing details of the current user's account.") +(defvar mastodon-profile-acccount-preferences-data nil + "Holds the JSON data of the current user's preferences.") + (defvar mastodon-profile-update-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "C-c C-c") #'mastodon-profile--user-profile-send-updated) @@ -462,12 +465,16 @@ Returns the results as an alist." ;; used in tl.el (defun mastodon-profile--get-preferences-pref (pref) "Fetch PREF from the endpoint \"/preferences\". -This endpoint only holds a few preferences. For others, see +If `mastodon-profile-acccount-preferences-data' is set, fetch +from that instead. +The endpoint only holds a few preferences. For others, see `mastodon-profile--update-preference' and its endpoint, \"/accounts/update_credentials.\"" (alist-get pref - (mastodon-http--get-json - (mastodon-http--api "preferences")))) + (or mastodon-profile-acccount-preferences-data + (setq mastodon-profile-acccount-preferences-data + (mastodon-http--get-json + (mastodon-http--api "preferences")))))) (defun mastodon-profile--view-preferences () "View user preferences in another window." -- cgit v1.2.3