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 -- 1 file changed, 2 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." -- 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