branch: elpa/mastodon
commit 5d826c5bb32e7ad2e8463f195357a4d9e4ed1162
Author: marty hiatt <martianhia...@disroot.org>
Commit: marty hiatt <martianhia...@disroot.org>

    pin toot: only reload if in own profile view. FIX #672.
---
 lisp/mastodon-tl.el   | 10 ++++++++++
 lisp/mastodon-toot.el | 13 ++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 5739fbd75f..e05d6c68e3 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2186,6 +2186,16 @@ call this function after it is set or use something 
else."
 This includes the update profile note buffer, but not the preferences one."
   (string-prefix-p "accounts" (mastodon-tl--endpoint nil :no-error)))
 
+(defun mastodon-tl--own-profile-buffer-p ()
+  "Return t if we are viewing our own profile buffer.
+We check that our account credientials id matches the endpoint id in the 
buffer spec, which if in a profile buffer is of the form 
\"accounts/$id/statuses\"."
+  (and (mastodon-tl--profile-buffer-p)
+       (let ((endpoint-id
+              (nth 1
+                   (split-string (mastodon-tl--endpoint) "/")))))
+       (string= (mastodon-auth--get-account-id)
+                endpoint-id)))
+
 (defun mastodon-tl--search-buffer-p ()
   "T if current buffer is a search buffer."
   (string-suffix-p "search" (mastodon-tl--endpoint nil :no-error)))
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 83c4d9be36..9ebb1ef0c7 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -106,6 +106,7 @@
 (autoload 'mastodon-tl--image-trans-check "mastodon-tl")
 (autoload 'mastodon-instance-data "mastodon")
 (autoload 'mastodon-create-poll "mastodon-transient")
+(autoload 'mastodon-tl--own-profile-buffer-p "mastodon-tl")
 
 ;; for mastodon-toot-translate-toot-text
 (autoload 'mastodon-tl--content "mastodon-tl")
@@ -647,11 +648,13 @@ Uses `lingva.el'."
     (if (not pinnable-p)
         (user-error "You can only pin your own toots")
       (when (y-or-n-p (format "%s this toot? " (capitalize action)))
-        (mastodon-toot--action action
-                               (lambda (_)
-                                 (when mastodon-tl--buffer-spec
-                                   (mastodon-tl--reload-timeline-or-profile))
-                                 (message "Toot %s!" msg)))))))
+        (mastodon-toot--action
+         action
+         (lambda (_)
+           ;; let's only reload when in own profile view:
+           (when (mastodon-tl--own-profile-buffer-p)
+             (mastodon-tl--reload-timeline-or-profile))
+           (message "Toot %s!" msg)))))))
 
 
 ;;; DELETE, DRAFT, REDRAFT

Reply via email to