Allow pinning polls (#7922)

* Allow pinning polls

Signed-off-by: Robin Townsend <robin@robin.town>

* Show responses to pinned polls

Signed-off-by: Robin Townsend <robin@robin.town>

* Use enums more

Signed-off-by: Robin Townsend <robin@robin.town>
This commit is contained in:
Robin 2022-03-04 09:26:13 -05:00 committed by GitHub
parent 881307e97c
commit 3099a75a5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 1 deletions

View file

@ -15,8 +15,19 @@ limitations under the License.
*/
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { EventType } from "matrix-js-sdk/src/@types/event";
import { M_POLL_START } from "matrix-events-sdk";
export default class PinningUtils {
/**
* Event types that may be pinned.
*/
static pinnableEventTypes: (EventType | string)[] = [
EventType.RoomMessage,
M_POLL_START.name,
M_POLL_START.altName,
];
/**
* Determines if the given event may be pinned.
* @param {MatrixEvent} event The event to check.
@ -24,7 +35,7 @@ export default class PinningUtils {
*/
static isPinnable(event: MatrixEvent): boolean {
if (!event) return false;
if (event.getType() !== "m.room.message") return false;
if (!this.pinnableEventTypes.includes(event.getType())) return false;
if (event.isRedacted()) return false;
return true;