[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/mastodon 2af648cb28 04/18: try to respect thread CW fold s
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/mastodon 2af648cb28 04/18: try to respect thread CW fold status on update/more. #619. |
Date: |
Thu, 21 Nov 2024 13:00:18 -0500 (EST) |
branch: elpa/mastodon
commit 2af648cb280a09d674ac0e69db026cb78ad77ff5
Author: marty hiatt <martianhiatus@disroot.org>
Commit: marty hiatt <martianhiatus@disroot.org>
try to respect thread CW fold status on update/more. #619.
we set a buffer prop if whole thread is toggled and respect it on
re-loading.
---
lisp/mastodon-tl.el | 58 ++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 40 insertions(+), 18 deletions(-)
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 26ad4d9bfc..799b54b1fa 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1211,15 +1211,16 @@ content should be hidden."
(defun mastodon-tl--toggle-spoiler-text (position)
"Toggle the visibility of the spoiler text at/after POSITION."
- (let ((inhibit-read-only t)
- (spoiler-region (mastodon-tl--find-property-range
- 'mastodon-content-warning-body position nil)))
+ (let* ((inhibit-read-only t)
+ (spoiler-region (mastodon-tl--find-property-range
+ 'mastodon-content-warning-body position nil))
+ (new-state (not (get-text-property (car spoiler-region)
+ 'invisible))))
(if (not spoiler-region)
(user-error "No spoiler text here")
(add-text-properties (car spoiler-region) (cdr spoiler-region)
- (list 'invisible
- (not (get-text-property (car spoiler-region)
- 'invisible)))))))
+ (list 'invisible new-state))
+ new-state))) ;; return what we set invisibility to
(defun mastodon-tl--toggle-spoiler-text-in-toot ()
"Toggle the visibility of the spoiler text in the current toot."
@@ -1254,7 +1255,11 @@ content should be hidden."
(let* ((json (mastodon-tl--property 'item-json :no-move))
(cw (alist-get 'spoiler_text json)))
(when (not (string= "" cw))
- (mastodon-tl--toggle-spoiler-text-in-toot))))))))
+ (let ((new-state
+ (not
+ (mastodon-tl--toggle-spoiler-text-in-toot))))
+ (plist-put mastodon-tl--buffer-spec
+ 'thread-unfolded new-state)))))))))
(defun mastodon-tl--spoiler (toot &optional filter)
"Render TOOT with spoiler message.
@@ -2325,8 +2330,11 @@ view all branches of a thread."
(let ((id (mastodon-tl--property 'base-item-id)))
(mastodon-tl--thread id))))
-(defun mastodon-tl--thread (&optional thread-id)
- "Open thread buffer for toot at point or with THREAD-ID."
+(defun mastodon-tl--thread (&optional thread-id unfolded-state)
+ "Open thread buffer for toot at point or with THREAD-ID.
+UNFOLDED STATE is a boolean of whether the thread (we are
+reloading) is fully unfolded or folded, i.e. via
+`mastodon-tl--toggle-spoiler-in-thread'."
(interactive)
;; no toot-at-point macro here as we can call this programmatically, eg from
;; `mastodon-url-lookup'
@@ -2334,7 +2342,10 @@ view all branches of a thread."
;; if we provide the arg (e.g. url-lookup), the macro definition overrides
;; it, making the optional arg unusable!
(let* ((id (or thread-id (mastodon-tl--property 'base-item-id :no-move)))
- (type (mastodon-tl--field 'type (mastodon-tl--property 'item-json
:no-move))))
+ (type (mastodon-tl--field 'type
+ (mastodon-tl--property 'item-json
:no-move)))
+ ;; if reloading and thread was fully unfolded, respect it:
+ (mastodon-tl--expand-content-warnings unfolded-state))
(if (or (string= type "follow_request")
(string= type "follow")) ; no can thread these
(user-error "No thread")
@@ -2359,6 +2370,9 @@ view all branches of a thread."
(mastodon-tl--set-buffer-spec buffer endpoint
#'mastodon-tl--thread
nil nil nil nil id)
+ (when unfolded-state
+ (plist-put mastodon-tl--buffer-spec
+ 'thread-unfolded unfolded-state))
(mastodon-tl--timeline (alist-get 'ancestors context) :thread)
(goto-char (point-max))
(move-marker marker (point))
@@ -3048,12 +3062,16 @@ MAX-ID is the pagination parameter, a string."
(mastodon-tl--get-link-header-from-response headers)))
(goto-char (point-max))
(if (eq 'thread (mastodon-tl--get-buffer-type))
- ;; if thread view, call --thread with parent ID
- (progn (goto-char (point-min))
- (mastodon-tl--goto-next-item)
- (funcall (mastodon-tl--update-function))
- (goto-char point-before)
- (message "Loaded full thread."))
+ ;; if thread fully unfolded, respect it:
+ (let ((unfolded-state
+ (mastodon-tl--buffer-property 'thread-unfolded
+ (current-buffer) :noerror)))
+ ;; if thread view, call --thread with parent ID
+ (progn (goto-char (point-min))
+ (mastodon-tl--goto-next-item)
+ (mastodon-tl--thread nil unfolded-state)
+ (goto-char point-before)
+ (message "Loaded full thread.")))
(if (not json)
(user-error "No more results")
(funcall (mastodon-tl--update-function) json)
@@ -3248,8 +3266,12 @@ This location is defined by a non-nil value of
;; update a thread, without calling `mastodon-tl--updated-json':
(if (mastodon-tl--buffer-type-eq 'thread)
;; load whole thread:
- (let ((thread-id (mastodon-tl--thread-parent-id)))
- (funcall update-function thread-id)
+ (let ((thread-id (mastodon-tl--thread-parent-id))
+ ;; if thread fully unfolded, respect it:
+ (unfolded-state
+ (mastodon-tl--buffer-property 'thread-unfolded
+ (current-buffer) :noerror)))
+ (mastodon-tl--thread thread-id unfolded-state)
(message "Loaded full thread."))
;; update other timelines:
(let* ((id (mastodon-tl--newest-id))
- [nongnu] elpa/mastodon 37bf064242 01/18: with-toot-item: no-move arg needed!, (continued)
- [nongnu] elpa/mastodon 37bf064242 01/18: with-toot-item: no-move arg needed!, ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon 62b973fde6 03/18: spoiler invis: fix respect of server setting, ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon 32963739da 02/18: unfold post: only get cw-invis when cw-range, ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon 6977dbbf5f 13/18: autoload with-toot-item macro, ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon ecb3b3dd69 07/18: profile.el: get-toot-author wrap in toot macro, ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon f9c7ad1a89 16/18: remove with-toot-item from --thread., ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon cf64163130 18/18: Merge branch 'develop', ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon de40a8d6cc 17/18: disable grouped notifs by default, so we don't break incompat instances, ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon 4d5b51ee72 15/18: check instance version for grouped-notifs, ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon f152b11732 08/18: separate thread-do function, ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon 2af648cb28 04/18: try to respect thread CW fold status on update/more. #619.,
ELPA Syncer <=
- [nongnu] elpa/mastodon 5b13b69209 10/18: three-way state for thread folded status. #620 (wip), ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon 4c29f39c3a 05/18: readme typo, ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon 5c8c559105 12/18: custom grouped notifs names count. + flychecks. FIX #603, ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon 36cfa5a68e 11/18: FIX #620. fetch thread-folded from buffer-spec in --thread, no arg., ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon 9f3e5d71af 09/18: thread fall back to setting if no unfolded-state. #620 (not fixed), ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon 6112232a7a 14/18: check instance version for grouped-notifs, ELPA Syncer, 2024/11/21
- [nongnu] elpa/mastodon 5c54f95aa8 06/18: foll req: use display name if poss for action str, ELPA Syncer, 2024/11/21