@@ -62,29 +62,18 @@ export default class PinningUtils {
6262 }
6363
6464 /**
65- * Determines if the given event may be pinned or unpinned by the current user
66- * It doesn't check if the event is pinnable or unpinnable .
65+ * Determines if the given event may be pinned by the current user.
66+ * This checks if the user has the necessary permissions to pin or unpin the event, and if the event is pinnable.
6767 * @param matrixClient
6868 * @param mxEvent
69- * @private
7069 */
71- private static canPinOrUnpin ( matrixClient : MatrixClient , mxEvent : MatrixEvent ) : boolean {
70+ public static canPin ( matrixClient : MatrixClient , mxEvent : MatrixEvent ) : boolean {
7271 if ( ! isContentActionable ( mxEvent ) ) return false ;
7372
7473 const room = matrixClient . getRoom ( mxEvent . getRoomId ( ) ) ;
7574 if ( ! room ) return false ;
7675
77- return PinningUtils . userHasPinOrUnpinPermission ( matrixClient , room ) ;
78- }
79-
80- /**
81- * Determines if the given event may be pinned by the current user.
82- * This checks if the user has the necessary permissions to pin or unpin the event, and if the event is pinnable.
83- * @param matrixClient
84- * @param mxEvent
85- */
86- public static canPin ( matrixClient : MatrixClient , mxEvent : MatrixEvent ) : boolean {
87- return PinningUtils . canPinOrUnpin ( matrixClient , mxEvent ) && PinningUtils . isPinnable ( mxEvent ) ;
76+ return PinningUtils . userHasPinOrUnpinPermission ( matrixClient , room ) && PinningUtils . isPinnable ( mxEvent ) ;
8877 }
8978
9079 /**
@@ -94,7 +83,10 @@ export default class PinningUtils {
9483 * @param mxEvent
9584 */
9685 public static canUnpin ( matrixClient : MatrixClient , mxEvent : MatrixEvent ) : boolean {
97- return PinningUtils . canPinOrUnpin ( matrixClient , mxEvent ) && PinningUtils . isUnpinnable ( mxEvent ) ;
86+ const room = matrixClient . getRoom ( mxEvent . getRoomId ( ) ) ;
87+ if ( ! room ) return false ;
88+
89+ return PinningUtils . userHasPinOrUnpinPermission ( matrixClient , room ) && PinningUtils . isUnpinnable ( mxEvent ) ;
9890 }
9991
10092 /**
0 commit comments