@@ -62,29 +62,18 @@ export default class PinningUtils {
62
62
}
63
63
64
64
/**
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.
67
67
* @param matrixClient
68
68
* @param mxEvent
69
- * @private
70
69
*/
71
- private static canPinOrUnpin ( matrixClient : MatrixClient , mxEvent : MatrixEvent ) : boolean {
70
+ public static canPin ( matrixClient : MatrixClient , mxEvent : MatrixEvent ) : boolean {
72
71
if ( ! isContentActionable ( mxEvent ) ) return false ;
73
72
74
73
const room = matrixClient . getRoom ( mxEvent . getRoomId ( ) ) ;
75
74
if ( ! room ) return false ;
76
75
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 ) ;
88
77
}
89
78
90
79
/**
@@ -94,7 +83,10 @@ export default class PinningUtils {
94
83
* @param mxEvent
95
84
*/
96
85
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 ) ;
98
90
}
99
91
100
92
/**
0 commit comments