From e6bdc008ed3f66fd5c6903c491e1cf6d4dafd2f3 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 21 May 2024 12:40:19 +0200 Subject: profiles: support only-media arg --- lisp/mastodon-profile.el | 30 +++++++++++++++++++++--------- lisp/mastodon-tl.el | 2 ++ 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 2a5e350..fc318e2 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -142,11 +142,12 @@ contains") (mastodon-tl--property 'item-json)) (defun mastodon-profile--make-author-buffer - (account &optional no-reblogs no-replies) + (account &optional no-reblogs no-replies only-media) "Take an ACCOUNT json and insert a user account into a new buffer. NO-REBLOGS means do not display boosts in statuses." (mastodon-profile--make-profile-buffer-for - account "statuses" #'mastodon-tl--timeline no-reblogs nil no-replies)) + account "statuses" #'mastodon-tl--timeline no-reblogs nil + no-replies only-media)) ;; TODO: we shd just load all views' data then switch coz this is slow af: (defun mastodon-profile--account-view-cycle () @@ -157,6 +158,8 @@ NO-REBLOGS means do not display boosts in statuses." ((mastodon-tl--buffer-type-eq 'profile-statuses-no-boosts) (mastodon-profile--open-statuses-no-replies)) ((mastodon-tl--buffer-type-eq 'profile-statuses-no-replies) + (mastodon-profile--open-statuses-only-media)) + ((mastodon-tl--buffer-type-eq 'profile-statuses-only-media) (mastodon-profile--open-followers)) ((mastodon-tl--buffer-type-eq 'profile-followers) (mastodon-profile--open-following)) @@ -179,6 +182,14 @@ NO-REBLOGS means do not display boosts in statuses." mastodon-profile--account :no-reblogs) (user-error "Not in a mastodon profile"))) +(defun mastodon-profile--open-statuses-only-media () + "Open a profile buffer showing only statuses with media." + (interactive) + (if mastodon-profile--account + (mastodon-profile--make-author-buffer + mastodon-profile--account nil nil :only-media) + (user-error "Not in a mastodon profile"))) + (defun mastodon-profile--open-following () "Open a profile buffer showing the accounts that current profile follows." (interactive) @@ -567,7 +578,7 @@ FIELDS means provide a fields vector fetched by other means." (defun mastodon-profile--make-profile-buffer-for (account endpoint-type update-function - &optional no-reblogs headers no-replies) + &optional no-reblogs headers no-replies only-media) "Display profile of ACCOUNT, using ENDPOINT-TYPE and UPDATE-FUNCTION. NO-REBLOGS means do not display boosts in statuses. HEADERS means also fetch link headers for pagination." @@ -577,17 +588,18 @@ HEADERS means also fetch link headers for pagination." (push '("exclude_reblogs" . "t") args)) (no-replies (push '("exclude_replies" . "t") args)) + (only-media + (push '("only_media" . "t") args)) (t args))) (endpoint (format "accounts/%s/%s" .id endpoint-type)) (url (mastodon-http--api endpoint)) (buffer (concat "*mastodon-" .acct "-" - (cond (no-reblogs - (concat endpoint-type "-no-boosts")) - (no-replies - (concat endpoint-type "-no-replies")) - (t - endpoint-type)) + (concat endpoint-type + (cond (no-reblogs "-no-boosts") + (no-replies "-no-replies") + (only-media "-only-media") + (t ""))) "*")) (response (if headers (mastodon-http--get-response url args) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index fa0c7bb..6c444d4 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1677,6 +1677,8 @@ call this function after it is set or use something else." 'profile-statuses-no-boosts) ((string-suffix-p "no-replies*" buffer-name) 'profile-statuses-no-replies) + ((string-suffix-p "only-media*" buffer-name) + 'profile-statuses-only-media) ((mastodon-tl--endpoint-str-= "statuses" :suffix) 'profile-statuses) ;; profile followers -- cgit v1.2.3