From 1adb3e8583f8ec851cb2420c8cfede1192d017b7 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 17 Aug 2024 10:28:06 +0200 Subject: process-image-response (change args order) --- lisp/mastodon-media.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index d386462..ce2f8f5 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -273,7 +273,7 @@ IBCAQICX9F8/bNVInwJ8BAAAAABJRU5ErkJggg==") "The PNG data for a sensitive image placeholder.") (defun mastodon-media--process-image-response - (status-plist marker image-options region-length url) + (status-plist url marker image-options region-length) "Callback function processing the url retrieve response for URL. STATUS-PLIST is the usual plist of status events as per `url-retrieve'. IMAGE-OPTIONS are the precomputed options to apply to the image. @@ -390,7 +390,7 @@ REGION-LENGTH is the range from start to propertize." (mastodon-media--image-or-cached url #'mastodon-media--process-image-response - (list nil marker image-options region-length url)) + (list nil url marker image-options region-length)) (error (with-current-buffer buffer ;; TODO: Add retries (put-text-property marker (+ marker region-length) -- cgit v1.2.3 From aa9b4a7dd180bd27bc7ebb43bd2ca58c9b01de7f Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 17 Aug 2024 10:28:24 +0200 Subject: image-or-cached, apply not funcall. FIX #577. --- lisp/mastodon-media.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index ce2f8f5..620aa51 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -359,7 +359,8 @@ STATUS-PLIST is a plist of status events as per `url-retrieve'." (defun mastodon-media--image-or-cached (url process-fun args) "Fetch URL from cache or fro host. -Call PROCESS-FUN on it with ARGS." +Call PROCESS-FUN on it with ARGS, a list of callback args as +specified by `url-retrieve'." (if (and mastodon-media--enable-image-caching (url-is-cached url)) ;; if cached, decompress and use: (with-current-buffer (url-fetch-from-cache url) @@ -367,8 +368,9 @@ Call PROCESS-FUN on it with ARGS." (goto-char (point-min)) (zlib-decompress-region (goto-char (search-forward "\n\n")) (point-max)) - (funcall process-fun url args)) - ;; fetch as usual and process-image-response will cache it + (apply process-fun args)) ;; no status-plist arg from cache + ;; fetch as usual and process-image-response will cache it: + ;; cbargs fun will be called with status-plist by url-retrieve: (url-retrieve url process-fun (cdr args)))) (defun mastodon-media--load-image-from-url (url media-type start region-length) -- cgit v1.2.3 From 0a6040242293d60f65975c6d085dda994980ed57 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 17 Aug 2024 11:57:30 +0200 Subject: fix mute or unmute: use top level id to check if we posted --- lisp/mastodon-tl.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 0d5d8a9..91f42d0 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2183,7 +2183,7 @@ Note that you can only (un)mute threads you have posted in." (mastodon-tl--mute-or-unmute-thread)) (defun mastodon-tl--unmute-thread () - "Mute the thread displayed in the current buffer. + "Unmute the thread displayed in the current buffer. Note that you can only (un)mute threads you have posted in." (interactive) (mastodon-tl--mute-or-unmute-thread :unmute)) @@ -2196,23 +2196,23 @@ If UNMUTE, unmute it." (when (or (mastodon-tl--buffer-type-eq 'thread) (mastodon-tl--buffer-type-eq 'notifications)) (let* ((id + ;; if in a thread, the id to call `mastodon-tl--user-in-thread-p' on + ;; really ought to be the top level item (if (mastodon-tl--buffer-type-eq 'notifications) - (get-text-property (point) 'base-item-id) - (save-match-data - (string-match "statuses/\\(?2:[[:digit:]]+\\)/context" - endpoint) - (match-string 2 endpoint)))) + (mastodon-tl--property 'base-item-id :no-move) + (save-excursion + (mastodon-tl--goto-first-item) + (mastodon-tl--property 'base-item-id :no-move)))) (we-posted-p (mastodon-tl--user-in-thread-p id)) (url (mastodon-http--api (format "statuses/%s/%s" id mute-str)))) (if (not we-posted-p) - (message "You can only (un)mute a thread you have posted in.") + (user-error "You can only (un)mute a thread you have posted in") (when (y-or-n-p (format "%s this thread? " (capitalize mute-str))) (let ((response (mastodon-http--post url))) - (mastodon-http--triage response - (lambda (_) - (if unmute - (message "Thread unmuted!") - (message "Thread muted!"))))))))))) + (mastodon-http--triage + response + (lambda (_) + (message (format "Thread %sd!" mute-str))))))))))) (defun mastodon-tl--map-account-id-from-toot (statuses) "Return a list of the account IDs of the author of each toot in STATUSES." -- cgit v1.2.3