ignoreSelfEvent -> shouldCauseReorder

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Šimon Brandner 2021-08-25 08:43:13 +02:00
parent b7df1127bd
commit 0465815486
No known key found for this signature in database
GPG Key ID: 55C211A1226CB17D
1 changed files with 6 additions and 6 deletions

View File

@ -23,21 +23,21 @@ import { EffectiveMembership, getEffectiveMembership } from "../../../../utils/m
import { EventType } from "matrix-js-sdk/src/@types/event"; import { EventType } from "matrix-js-sdk/src/@types/event";
import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { MatrixEvent } from "matrix-js-sdk/src/models/event";
export function ignoreSelfEvent(event: MatrixEvent): boolean { export function shouldCauseReorder(event: MatrixEvent): boolean {
const type = event.getType(); const type = event.getType();
const content = event.getContent(); const content = event.getContent();
const prevContent = event.getPrevContent(); const prevContent = event.getPrevContent();
// Never ignore membership changes // Never ignore membership changes
if (type === EventType.RoomMember && prevContent.membership !== content.membership) return false; if (type === EventType.RoomMember && prevContent.membership !== content.membership) return true;
// Ignore status changes // Ignore status changes
// XXX: This should be an enum // XXX: This should be an enum
if (type === "im.vector.user_status") return true; if (type === "im.vector.user_status") return false;
// Ignore display name changes // Ignore display name changes
if (type === EventType.RoomMember && prevContent.displayname !== content.displayname) return true; if (type === EventType.RoomMember && prevContent.displayname !== content.displayname) return false;
return false; return true;
} }
export const sortRooms = (rooms: Room[]): Room[] => { export const sortRooms = (rooms: Room[]): Room[] => {
@ -88,7 +88,7 @@ export const sortRooms = (rooms: Room[]): Room[] => {
if (!ev.getTs()) continue; // skip events that don't have timestamps (tests only?) if (!ev.getTs()) continue; // skip events that don't have timestamps (tests only?)
if ( if (
(ev.getSender() === myUserId && !ignoreSelfEvent(ev)) || (ev.getSender() === myUserId && shouldCauseReorder(ev)) ||
Unread.eventTriggersUnreadCount(ev) Unread.eventTriggersUnreadCount(ev)
) { ) {
return ev.getTs(); return ev.getTs();