From 87705c415d6ec3bbf2ed13b844d9c8d1400f1fa4 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 5 Sep 2022 12:50:07 +0200 Subject: use seq-empty-p and string-empty-p calls --- lisp/mastodon-profile.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 00ffedd..cf27732 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -201,7 +201,7 @@ JSON is the data returned by the server." (mastodon-tl--set-face "[a/r - accept/reject request at point\n n/p - go to next/prev request]\n\n" 'font-lock-comment-face)) - (if (equal json '[]) + (if (seq-empty-p json) (insert (propertize "Looks like you have no follow requests for now." 'face font-lock-comment-face @@ -538,7 +538,7 @@ Also insert their profile note. Used to view a user's followers and those they're following." ;;FIXME change the name of this fun now that we've edited what it does! (let ((inhibit-read-only t)) - (when (not (equal tootv '[])) + (unless (seq-empty-p tootv) (mapc (lambda (toot) (let ((start-pos (point))) (insert "\n" -- cgit v1.2.3 From b2b33d85ef21b82059ecf97518795cd94221c576 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 10 Sep 2022 18:22:29 +0200 Subject: `mastodon-profile-account-settings` fetch on enter major mode --- lisp/mastodon-profile.el | 36 ++++++++++++++++++++++++++++++++++++ lisp/mastodon-toot.el | 27 ++++++++++++++++++--------- 2 files changed, 54 insertions(+), 9 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index cf27732..3065621 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -35,6 +35,7 @@ ;;; Code: (require 'seq) (require 'cl-lib) +(require 'persist) (autoload 'mastodon-http--api "mastodon-http.el") (autoload 'mastodon-http--get-json "mastodon-http.el") @@ -67,10 +68,12 @@ (autoload 'mastodon-toot "mastodon") (autoload 'mastodon-search--insert-users-propertized "mastodon-search") (autoload 'mastodon-tl--get-endpoint "mastodon-tl.el") +(autoload 'mastodon-toot--get-max-toot-chars "mastodon-toot") (defvar mastodon-instance-url) (defvar mastodon-tl--buffer-spec) (defvar mastodon-tl--update-point) (defvar mastodon-mode-map) +(defvar mastodon-toot--max-toot-chars) (defvar-local mastodon-profile--account nil "The data for the account being described in the current profile buffer.") @@ -116,6 +119,9 @@ extra keybindings." map) "Keymap for `mastodon-profile-update-mode'.") +(persist-defvar mastodon-profile-account-settings nil + "An alist of account settings saved from the server.") + (define-minor-mode mastodon-profile-update-mode "Minor mode to update Mastodon user profile." :group 'mastodon-profile @@ -267,8 +273,38 @@ SOURCE means that the preference is in the 'source' part of the account json." (response (mastodon-http--patch url `((,pref-formatted ,val))))) (mastodon-http--triage response (lambda () + (mastodon-profile-update-preference-alist pref val) (message "Account setting %s updated to %s!" pref val))))) +(defun mastodon-profile-update-preference-alist (pref val) + "Set local account preference plist preference PREF to VAL. +This is done after changing the setting on the server." + (setf (plist-get mastodon-profile-account-settings pref) val)) + +(defun mastodon-profile-fetch-server-account-settings () + "Fetch basic account settings from the server. +Store the values in `mastodon-profile-account-settings'. +Run in `mastodon-mode-hook'." + ;; TODO: add some server settings like max_chars + (let ((keys '(locked discoverable display_name)) + (source-keys '(privacy))) + ;; (instance-keys '(max_toot_chars))) + (mapc (lambda (k) + (mastodon-profile-update-preference-alist + k + (mastodon-profile--get-json-value k))) + keys) + (mapc (lambda (sk) + (mastodon-profile-update-preference-alist + sk + (mastodon-profile--get-source-pref sk))) + source-keys) + ;; hack for max toot chars: + (mastodon-toot--get-max-toot-chars :no-toot) + (mastodon-profile-update-preference-alist 'max_toot_chars + mastodon-toot--max-toot-chars) + mastodon-profile-account-settings)) + (defun mastodon-profile-account-locked-toggle () "Toggle the locked status of your account. Locked accounts mean follow requests have to be manually approved." diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 7048996..2f58bfb 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -143,13 +143,15 @@ This is only used if company mode is installed." '(direct private unlisted public) "A list of the available toot visibility settings.") -(defvar-local mastodon-toot--visibility "public" +(defvar-local mastodon-toot--visibility nil "A string indicating the visibility of the toot being composed. Valid values are \"direct\", \"private\" (followers-only), \"unlisted\", and \"public\". -This may be set by the account setting on the server.") +This is determined by the account setting on the server. To +change the setting on the server, see +`mastodon-toot-set-default-visibility'.") (defvar-local mastodon-toot--media-attachments nil "A list of the media attachments of the toot being composed.") @@ -194,12 +196,12 @@ send.") nil t))) (mastodon-profile--update-preference "privacy" vis :source))) -(defun mastodon-toot--get-max-toot-chars () +(defun mastodon-toot--get-max-toot-chars (&optional no-toot) "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)) + (mastodon-http--api "instance") 'mastodon-toot--get-max-toot-chars-callback 'no-toot)) -(defun mastodon-toot--get-max-toot-chars-callback (json-response) +(defun mastodon-toot--get-max-toot-chars-callback (json-response &optional no-toot) "Set max_toot_chars returned in JSON-RESPONSE and display in new toot buffer." (let ((max-chars (or @@ -210,8 +212,9 @@ send.") (alist-get 'configuration json-response)))))) (setq mastodon-toot--max-toot-chars max-chars) - (with-current-buffer "*new toot*" - (mastodon-toot--update-status-fields)))) + (unless no-toot + (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. @@ -1118,6 +1121,8 @@ Added to `after-change-functions' in new toot buffers." "Return t if compose buffer is current." (equal (buffer-name (current-buffer)) "*new toot*")) +;; NB: now that we have toot drafts, to ensure offline composing remains +;; possible, avoid any direct requests here: (defun mastodon-toot--compose-buffer (&optional reply-to-user reply-to-id reply-json initial-text) "Create a new buffer to capture text for a new toot. @@ -1133,15 +1138,19 @@ a draft into the buffer." (switch-to-buffer-other-window buffer) (text-mode) (mastodon-toot-mode t) - ;; use toot visibility setting from the server: (setq mastodon-toot--visibility - (mastodon-profile--get-source-pref 'privacy)) + (or (plist-get mastodon-profile-account-settings 'privacy) + ;; use toot visibility setting from the server: + (mastodon-profile--get-source-pref 'privacy) + "public")) ; fallback (unless buffer-exists (mastodon-toot--display-docs-and-status-fields (when mastodon-toot-display-orig-in-reply-buffer reply-text)) (mastodon-toot--setup-as-reply reply-to-user reply-to-id reply-json)) (unless mastodon-toot--max-toot-chars + ;; no need to fetch from `mastodon-profile-account-settings' as + ;; `mastodon-toot--max-toot-chars' is set when we set it (mastodon-toot--get-max-toot-chars)) ;; set up company backends: (when (require 'company nil :noerror) -- cgit v1.2.3 From f3c05b9e17c43edc5ab0f7f7e06f87aeeca9283b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 11 Sep 2022 12:12:43 +0200 Subject: add 'sensitive' 'bot' and 'language' settings --- lisp/mastodon-profile.el | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 3065621..8b19863 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -216,7 +216,7 @@ JSON is the data returned by the server." (mastodon-search--insert-users-propertized json :note))) ;; (mastodon-profile--add-author-bylines json))) -;;; account preferences +;;; ACCOUNT PREFERENCES (defun mastodon-profile--get-json-value (val) "Fetch current VAL ue from account." @@ -285,10 +285,8 @@ This is done after changing the setting on the server." "Fetch basic account settings from the server. Store the values in `mastodon-profile-account-settings'. Run in `mastodon-mode-hook'." - ;; TODO: add some server settings like max_chars - (let ((keys '(locked discoverable display_name)) - (source-keys '(privacy))) - ;; (instance-keys '(max_toot_chars))) + (let ((keys '(locked discoverable display_name bot)) + (source-keys '(privacy sensitive language))) (mapc (lambda (k) (mastodon-profile-update-preference-alist k @@ -307,7 +305,7 @@ Run in `mastodon-mode-hook'." (defun mastodon-profile-account-locked-toggle () "Toggle the locked status of your account. -Locked accounts mean follow requests have to be manually approved." +Locked means follow requests have to be approved." (interactive) (mastodon-profile--toggle-account-key 'locked)) @@ -317,9 +315,24 @@ Discoverable means the account is listed in the server directory." (interactive) (mastodon-profile--toggle-account-key 'discoverable)) -(defun mastodon-profile--toggle-account-key (key) - "Toggle the boolean account setting KEY." - (let* ((val (mastodon-profile--get-json-value key)) +(defun mastodon-profile-account-bot-toggle () + "Toggle the bot status of your account." + (interactive) + (mastodon-profile--toggle-account-key 'bot)) + +;; TODO: actually respect "sensitive" account setting +(defun mastodon-profile-account-sensitive-toggle () + "Toggle the sensitive status of your account. +When enabled, statuses are marked as sensitive by default." + (interactive) + (mastodon-profile--toggle-account-key 'sensitive)) + +(defun mastodon-profile--toggle-account-key (key &optional source) + "Toggle the boolean account setting KEY. +SOURCE means the setting is located under \"source\" in the account JSON." + (let* ((val (if source + (mastodon-profile--get-source-pref key) + (mastodon-profile--get-json-value key))) (prompt (format "Account setting %s is %s. Toggle?" key val))) (if (not (equal val :json-false)) (when (y-or-n-p prompt) @@ -360,6 +373,8 @@ Discoverable means the account is listed in the server directory." "\n\n")))) (goto-char (point-min))))) +;; PROFILE VIEW DETAILS + (defun mastodon-profile--relationships-get (id) "Fetch info about logged-in user's relationship to user with id ID." (let* ((their-id id) -- cgit v1.2.3 From 5f9c329d6b8a8e309490b21c768cbfa8083d654e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 11 Sep 2022 12:37:45 +0200 Subject: set nsfw and visibility vars from our account-prefs plist - we cd remove these vars entirely and just use the plis + accessor fun --- lisp/mastodon-profile.el | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 8b19863..87e00a4 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -273,12 +273,18 @@ SOURCE means that the preference is in the 'source' part of the account json." (response (mastodon-http--patch url `((,pref-formatted ,val))))) (mastodon-http--triage response (lambda () - (mastodon-profile-update-preference-alist pref val) + (mastodon-profile-update-preference-plist pref val) (message "Account setting %s updated to %s!" pref val))))) -(defun mastodon-profile-update-preference-alist (pref val) +(defun mastodon-profile--get-pref (pref) + "Return PREF from `mastodon-profile-account-settings'." + (plist-get mastodon-profile-account-settings pref)) + +(defun mastodon-profile-update-preference-plist (pref val) "Set local account preference plist preference PREF to VAL. This is done after changing the setting on the server." + ;; TODO: convert all :json-false to nil and back again on sending + ;; (let ((val (if (eql :json-false val) nil val))) (setf (plist-get mastodon-profile-account-settings pref) val)) (defun mastodon-profile-fetch-server-account-settings () @@ -288,19 +294,22 @@ Run in `mastodon-mode-hook'." (let ((keys '(locked discoverable display_name bot)) (source-keys '(privacy sensitive language))) (mapc (lambda (k) - (mastodon-profile-update-preference-alist + (mastodon-profile-update-preference-plist k (mastodon-profile--get-json-value k))) keys) (mapc (lambda (sk) - (mastodon-profile-update-preference-alist + (mastodon-profile-update-preference-plist sk (mastodon-profile--get-source-pref sk))) source-keys) ;; hack for max toot chars: (mastodon-toot--get-max-toot-chars :no-toot) - (mastodon-profile-update-preference-alist 'max_toot_chars + (mastodon-profile-update-preference-plist 'max_toot_chars mastodon-toot--max-toot-chars) + ;; TODO: remove now redundant vars, replace with fetchers from the plist + (setq mastodon-toot--visibility (mastodon-profile--get-pref 'privacy) + mastodon-toot--content-nsfw (mastodon-profile--get-pref 'sensitive)) mastodon-profile-account-settings)) (defun mastodon-profile-account-locked-toggle () -- cgit v1.2.3 From a986ec502a305a9a55311bec8956b1f0331d2b16 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 11 Sep 2022 13:47:27 +0200 Subject: re-fetch acc settings from server after toggle --- lisp/mastodon-profile.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 87e00a4..e8b8622 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -273,7 +273,7 @@ SOURCE means that the preference is in the 'source' part of the account json." (response (mastodon-http--patch url `((,pref-formatted ,val))))) (mastodon-http--triage response (lambda () - (mastodon-profile-update-preference-plist pref val) + (mastodon-profile-fetch-server-account-settings) (message "Account setting %s updated to %s!" pref val))))) (defun mastodon-profile--get-pref (pref) @@ -284,8 +284,8 @@ SOURCE means that the preference is in the 'source' part of the account json." "Set local account preference plist preference PREF to VAL. This is done after changing the setting on the server." ;; TODO: convert all :json-false to nil and back again on sending - ;; (let ((val (if (eql :json-false val) nil val))) - (setf (plist-get mastodon-profile-account-settings pref) val)) + (setq mastodon-profile-account-settings + (plist-put mastodon-profile-account-settings pref val))) (defun mastodon-profile-fetch-server-account-settings () "Fetch basic account settings from the server. -- cgit v1.2.3 From 346c8cd43af5d5aba44291b018f7bf94e2ed335c Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 11 Sep 2022 16:13:44 +0200 Subject: remove stale TODOs and stale function --single-toot-from-url --- lisp/mastodon-profile.el | 2 -- lisp/mastodon-tl.el | 7 ------- 2 files changed, 9 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index e8b8622..a43b92f 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -283,7 +283,6 @@ SOURCE means that the preference is in the 'source' part of the account json." (defun mastodon-profile-update-preference-plist (pref val) "Set local account preference plist preference PREF to VAL. This is done after changing the setting on the server." - ;; TODO: convert all :json-false to nil and back again on sending (setq mastodon-profile-account-settings (plist-put mastodon-profile-account-settings pref val))) @@ -329,7 +328,6 @@ Discoverable means the account is listed in the server directory." (interactive) (mastodon-profile--toggle-account-key 'bot)) -;; TODO: actually respect "sensitive" account setting (defun mastodon-profile-account-sensitive-toggle () "Toggle the sensitive status of your account. When enabled, statuses are marked as sensitive by default." diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index db8ce20..d8b2baa 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1175,13 +1175,6 @@ webapp" (reblog (alist-get 'reblog json))) (if reblog (alist-get 'id reblog) id))) -(defun mastodon-tl--single-toot-from-url (url) - "Open the toot at URL in `mastodon.el'." - ;; TODO: test if URL is masto - ;; FIXME: this only works 1/2 the time - (let ((id (url-file-nondirectory url))) - (mastodon-tl--single-toot id))) - (defun mastodon-tl--single-toot (&optional id) "View toot at point in separate buffer. ID is that of the toot to view." -- cgit v1.2.3 From 4b543acd89a6f4b58469bdd39923f56f01e3d6e5 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 11 Sep 2022 16:24:40 +0200 Subject: fix toggle of source type prefs --- lisp/mastodon-profile.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index a43b92f..7ac0d31 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -332,7 +332,7 @@ Discoverable means the account is listed in the server directory." "Toggle the sensitive status of your account. When enabled, statuses are marked as sensitive by default." (interactive) - (mastodon-profile--toggle-account-key 'sensitive)) + (mastodon-profile--toggle-account-key 'sensitive :source)) (defun mastodon-profile--toggle-account-key (key &optional source) "Toggle the boolean account setting KEY. @@ -343,9 +343,9 @@ SOURCE means the setting is located under \"source\" in the account JSON." (prompt (format "Account setting %s is %s. Toggle?" key val))) (if (not (equal val :json-false)) (when (y-or-n-p prompt) - (mastodon-profile--update-preference (symbol-name key) "false")) + (mastodon-profile--update-preference (symbol-name key) "false" source)) (when (y-or-n-p prompt) - (mastodon-profile--update-preference (symbol-name key) "true"))))) + (mastodon-profile--update-preference (symbol-name key) "true" source))))) (defun mastodon-profile--edit-account-string (key) "Edit the string for account setting KEY." -- cgit v1.2.3 From 0ecf1a91dff2b2a06e91dafb3526da2f579e63e2 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 12 Sep 2022 09:20:50 +0200 Subject: profile-account-settings docstring --- lisp/mastodon-profile.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 7ac0d31..b4e7f35 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -120,7 +120,11 @@ extra keybindings." "Keymap for `mastodon-profile-update-mode'.") (persist-defvar mastodon-profile-account-settings nil - "An alist of account settings saved from the server.") + "An alist of account settings saved from the server. +Other clients can change these settings on the server at any +time, so this list is not the canonical source for settings. It +is updated on entering mastodon mode and on toggle any setting it +contains") (define-minor-mode mastodon-profile-update-mode "Minor mode to update Mastodon user profile." -- cgit v1.2.3 From d75cdb248485696b7def7f4dc8e20af7e0738129 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 12 Sep 2022 09:23:22 +0200 Subject: rename --get-source-pref(s) to -value(s) --- lisp/mastodon-profile.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index b4e7f35..d44f6af 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -228,13 +228,13 @@ JSON is the data returned by the server." (response (mastodon-http--get-json url))) (alist-get val response))) -(defun mastodon-profile--get-source-prefs () +(defun mastodon-profile--get-source-values () "Return the \"source\" preferences from the server." (mastodon-profile--get-json-value 'source)) -(defun mastodon-profile--get-source-pref (pref) +(defun mastodon-profile--get-source-value (pref) "Return account PREF erence from the \"source\" section on the server." - (let ((source (mastodon-profile--get-source-prefs))) + (let ((source (mastodon-profile--get-source-values))) (alist-get pref source))) (defun mastodon-profile--update-user-profile-note () @@ -304,7 +304,7 @@ Run in `mastodon-mode-hook'." (mapc (lambda (sk) (mastodon-profile-update-preference-plist sk - (mastodon-profile--get-source-pref sk))) + (mastodon-profile--get-source-value sk))) source-keys) ;; hack for max toot chars: (mastodon-toot--get-max-toot-chars :no-toot) @@ -342,7 +342,7 @@ When enabled, statuses are marked as sensitive by default." "Toggle the boolean account setting KEY. SOURCE means the setting is located under \"source\" in the account JSON." (let* ((val (if source - (mastodon-profile--get-source-pref key) + (mastodon-profile--get-source-value key) (mastodon-profile--get-json-value key))) (prompt (format "Account setting %s is %s. Toggle?" key val))) (if (not (equal val :json-false)) -- cgit v1.2.3 From e7209bd1d404324cf5653b2728c1d219902e8f29 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 12 Sep 2022 09:32:14 +0200 Subject: docstrings & rename fun --- lisp/mastodon-profile.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index d44f6af..3b6f336 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -269,9 +269,9 @@ JSON is the data returned by the server." (lambda () (message "Profile note updated!")))))) (defun mastodon-profile--update-preference (pref val &optional source) - "Update a single acount PREF erence to setting VAL. + "Update account PREF erence to setting VAL. Both args are strings. -SOURCE means that the preference is in the 'source' part of the account json." +SOURCE means that the preference is in the 'source' part of the account JSON." (let* ((url (mastodon-http--api "accounts/update_credentials")) (pref-formatted (if source (concat "source[" pref "]") pref)) (response (mastodon-http--patch url `((,pref-formatted ,val))))) @@ -340,7 +340,8 @@ When enabled, statuses are marked as sensitive by default." (defun mastodon-profile--toggle-account-key (key &optional source) "Toggle the boolean account setting KEY. -SOURCE means the setting is located under \"source\" in the account JSON." +SOURCE means the setting is located under \"source\" in the account JSON. +Current settings are fetched from the server." (let* ((val (if source (mastodon-profile--get-source-value key) (mastodon-profile--get-json-value key))) @@ -351,8 +352,8 @@ SOURCE means the setting is located under \"source\" in the account JSON." (when (y-or-n-p prompt) (mastodon-profile--update-preference (symbol-name key) "true" source))))) -(defun mastodon-profile--edit-account-string (key) - "Edit the string for account setting KEY." +(defun mastodon-profile--edit-string-value (key) + "Edit the string for account preference KEY." (let* ((val (mastodon-profile--get-json-value key)) (new-val (read-string (format "Edit account setting %s: " key) @@ -362,7 +363,7 @@ SOURCE means the setting is located under \"source\" in the account JSON." (defun mastodon-profile-update-display-name () "Update display name for your account." (interactive) - (mastodon-profile--edit-account-string 'display_name)) + (mastodon-profile--edit-string-value 'display_name)) (defun mastodon-profile-view-preferences () "View user preferences in another window." -- cgit v1.2.3 From c9e702448548daac323983ac2fa42522801da4aa Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 12 Sep 2022 13:13:00 +0200 Subject: add account json to profile details in profile view --- lisp/mastodon-profile.el | 51 +++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 3b6f336..b404bb6 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -477,30 +477,33 @@ Returns a list of lists." (is-followers " FOLLOWERS ") (is-following " FOLLOWING ")))) (insert - "\n" - (mastodon-profile--image-from-account account) - "\n" - (propertize (mastodon-profile--account-field - account 'display_name) - 'face 'mastodon-display-name-face) - "\n" - (propertize (concat "@" acct) - 'face 'default) - (if (equal locked t) - (if (fontp (char-displayable-p #10r9993)) - " 🔒" - " [locked]") - "") - "\n ------------\n" - (mastodon-tl--render-text note account) - ;; account here to enable tab-stops in profile note - (if fields - (concat "\n" - (mastodon-tl--set-face - (mastodon-profile--fields-insert fields) - 'success) - "\n") - "") + (propertize + (concat + "\n" + (mastodon-profile--image-from-account account) + "\n" + (propertize (mastodon-profile--account-field + account 'display_name) + 'face 'mastodon-display-name-face) + "\n" + (propertize (concat "@" acct) + 'face 'default) + (if (equal locked t) + (if (fontp (char-displayable-p #10r9993)) + " 🔒" + " [locked]") + "") + "\n ------------\n" + (mastodon-tl--render-text note account) + ;; account here to enable tab-stops in profile note + (if fields + (concat "\n" + (mastodon-tl--set-face + (mastodon-profile--fields-insert fields) + 'success) + "\n") + "")) + 'profile-json account) ;; insert counts (mastodon-tl--set-face (concat " ------------\n" -- cgit v1.2.3 From 0b65ec90bd829530fe8bef843f873c3ecc6c0721 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 12 Sep 2022 16:26:45 +0200 Subject: respect user pref reading:expand:spoilers for CWs respect always expand CWd posts account preference --- lisp/mastodon-profile.el | 9 +++++++++ lisp/mastodon-tl.el | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index b404bb6..012e357 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -365,6 +365,15 @@ Current settings are fetched from the server." (interactive) (mastodon-profile--edit-string-value 'display_name)) +(defun mastodon-profile--get-preferences-pref (pref) + "Fetch PREF from the endpoint \"/preferences\". +This 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")))) + (defun mastodon-profile-view-preferences () "View user preferences in another window." (interactive) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d8b2baa..8e75705 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -66,6 +66,7 @@ (autoload 'mastodon-search--get-user-info "mastodon-search") (autoload 'mastodon-http--delete "mastodon-http") (autoload 'mastodon-profile--view-author-profile "mastodon-profile") +(autoload 'mastodon-profile--get-preferences-pref "mastodon-profile") (when (require 'mpv nil :no-error) (declare-function mpv-start "mpv")) @@ -856,7 +857,12 @@ message is a link which unhides/hides the main body." (concat cw (propertize (mastodon-tl--content toot) - 'invisible t + 'invisible + ;; check server setting to expand all spoilers: + (unless (eq t + (mastodon-profile--get-preferences-pref + 'reading:expand:spoilers)) + t) 'mastodon-content-warning-body t)))) (defun mastodon-tl--media (toot) -- cgit v1.2.3