diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-08-20 12:46:52 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-08-20 12:46:52 +0200 |
commit | 43baced1733b318a4fbe0a2ddba02c252f109c41 (patch) | |
tree | 7b0475d0d2f3e9b5164d10167a8372d8c95d9d38 /lisp/mastodon-profile.el | |
parent | b8838b8a2fb8932227c4daf2cf823ad9d0e1eea6 (diff) | |
parent | 7be929c123d8ce94934a8b6f7c214df1d0bc346f (diff) |
Merge branch 'develop'
Diffstat (limited to 'lisp/mastodon-profile.el')
-rw-r--r-- | lisp/mastodon-profile.el | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 5748fa3..b8a6114 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -78,6 +78,7 @@ (let ((map (make-sparse-keymap))) (define-key map (kbd "s") #'mastodon-profile--open-followers) (define-key map (kbd "g") #'mastodon-profile--open-following) + (define-key map (kbd "C-c C-c") #'mastodon-profile--account-view-cycle) map) "Keymap for `mastodon-profile-mode'.") @@ -88,7 +89,7 @@ (define-key map (kbd "a") #'mastodon-notifications--follow-request-accept) (define-key map (kbd "n") #'mastodon-tl--goto-next-item) (define-key map (kbd "p") #'mastodon-tl--goto-prev-item) - (define-key map (kbd "g") 'mastodon-profile--view-follow-requests) + (define-key map (kbd "g") #'mastodon-profile--view-follow-requests) ;; (define-key map (kbd "t") #'mastodon-toot) ;; (define-key map (kbd "q") #'kill-current-buffer) ;; (define-key map (kbd "Q") #'kill-buffer-and-window) @@ -130,6 +131,19 @@ extra keybindings." (mastodon-profile--make-profile-buffer-for account "statuses" #'mastodon-tl--timeline)) +;; TODO: we shd just load all views' data then switch coz this is slow af: +(defun mastodon-profile-account-view-cycle () + "Cycle through profile view: toots, followers, and following." + (interactive) + (let ((endpoint (plist-get mastodon-tl--buffer-spec 'endpoint))) + (cond ((string-suffix-p "statuses" endpoint) + (mastodon-profile--open-followers)) + ((string-suffix-p "followers" endpoint) + (mastodon-profile--open-following)) + (t + (mastodon-profile--make-profile-buffer-for + mastodon-profile--account "statuses" #'mastodon-tl--timeline))))) + (defun mastodon-profile--open-following () "Open a profile buffer showing the accounts that current profile follows." (interactive) @@ -239,37 +253,25 @@ JSON is the data returned by the server." (defun mastodon-profile--fields-get (account) "Fetch the fields vector (aka profile metadata) from profile of ACCOUNT. - Returns a list of lists." (let ((fields (mastodon-profile--account-field account 'fields))) (when fields - (mapcar - (lambda (el) - (list - (alist-get 'name el) - (alist-get 'value el))) - fields)))) + (mapcar (lambda (el) + (list (alist-get 'name el) + (alist-get 'value el))) + fields)))) (defun mastodon-profile--fields-insert (fields) "Format and insert field pairs (a.k.a profile metadata) in FIELDS." (let* ((car-fields (mapcar 'car fields)) - ;; (cdr-fields (mapcar 'cadr fields)) - ;; (cdr-fields-rendered - ;; (list - ;; (mapcar (lambda (x) - ;; (mastodon-tl--render-text x nil)) - ;; cdr-fields))) (left-width (car (sort (mapcar 'length car-fields) '>)))) - ;; (right-width (car (sort (mapcar 'length cdr-fields) '>)))) (mapconcat (lambda (field) (mastodon-tl--render-text (concat (format "_ %s " (car field)) (make-string (- (+ 1 left-width) (length (car field))) ?_) (format " :: %s" (cadr field))) - ;; (make-string (- (+ 1 right-width) (length (cdr field))) ?_) - ;; " |") - field)) ; nil)) ; hack to make links tabstops + field)) ; hack to make links tabstops fields ""))) (defun mastodon-profile--get-statuses-pinned (account) @@ -421,7 +423,8 @@ If toot is a boost, opens the profile of the booster." (if account (progn (message "Loading profile of user %s..." user-handle) - (mastodon-profile--make-author-buffer account)) + (mastodon-profile--make-author-buffer account) + (message "'C-c C-c' to cycle profile views: toots, followers, following")) (message "Cannot find a user with handle %S" user-handle))))) (defun mastodon-profile--my-profile () |